Set an unmanaged window as a parent to a WinForm form.

dapper

Assume we have the handle unmanaged window handle (e.g. by calling FindWindow).


/* GET THE HANDLE AS IntPtr */
IntPtr parentWindowHandle = IntPtr(...);
System.Windows.Forms.IWin32Window w = System.Windows.Forms.Control.FromHandle(parentWindowHandle);
MyForm myForm = new MyForm();
myForm.ShowDialog(w);
/* or myForm.Show(w) */

Post a Comment

Previous Post Next Post