Setting a Form's Parent using a Win32 Handle

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
 
C

Claes Bergefall

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

/claes
 
A

AlexS

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top