Setting a Form's Parent using a Win32 Handle

  • Thread starter Thread starter Joel
  • Start date Start date
J

Joel

I have written an add-in for Visual Studio using C#. During a long
operation I create a modeless form using the Show() method of the form. I
would like to set the parent of this form but all I have is a Win32 window
handle. Is there any way to tell the .NET form that it's parent is the
window represented by the Win32 window handle?

Thanks - Joel
 
Yes. Override the CreateParams property and specify your handle
in the Parent property of the corresponding structure

/claes
 
You need to use native API

[DllImport("user32.dll")]

internal static extern int SetParent(IntPtr hWndChild, IntPtr
hWndNewParent);



As you can see it is sufficient to have window handles to set parent.



HTH

Alex
 
Back
Top