How to "attach" a .NET Control to a HWND?

  • Thread starter Thread starter Lei Jiang
  • Start date Start date
L

Lei Jiang

I have a HWND, and I want to "attach" a WinFrom Control to it, how can I do
this?

The Control.FromHandle method can only find the control already exists.

Thanks!
 
AFAIK there is no way to attach a HWND to an instance of the Control class
Your only option is to use the NativeWindow class

/claes
 
Do you mean to set the control parent to a particular HWND? You could try
the SetParent win32 call.

[DllImport("user32")]

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



Called like so:

SetParent(this.Handle, IntPtr.Zero);


HTH;
Eric Cadwell
http://www.origincontrols.com
 
Back
Top