Guided by post
How can I run another application within a panel of my C# program?
I'm running the application in the panel of Webform. However top left corner of the application is not aligned with the top left corner of the panel.
Whatever the size of the panel is, it always shows big gaps between the panel edge and the app window.
Any ideas on how can I align the side app in the panel?
Code:
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
private void Form1_Load(object sender, EventArgs e)
{
ProcessStartInfo psi = new ProcessStartInfo("notepad.exe");
psi.WindowStyle = ProcessWindowStyle.Minimized;
Process p = Process.Start(psi);
Thread.Sleep(500);
SetParent(p.MainWindowHandle, panel1.Handle);
CenterToScreen();
psi.WindowStyle = ProcessWindowStyle.Normal;
}