I have a service page (actually a Win32 tab control panel) that I'd like to embed a C# .NET user control inside. The service manager app is Win32. As a test I thought I'd try parenting an instance of the user control to a Windows Form, not by adding it to the controls collection of the parent form but by using Win32's SetParent. When I do this however, my user control doesn't show on the form.
With:
[DllImport("user32.dll")]
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
I write:
if (My_User_Control_Instance == null)
{
My_User_Control_Instance = new My_New_User_Control();
}
My_User_Control_Instance .Bounds = position;
var result = SetParent(My_User_Control_Instance.Handle, hWnd);
where hWnd is an IntPtr acquired from the main forms .Handle.
With one eye on the eventual integration of this little applet with the Win32 application, what is the best way for me to do this? Or is the whole scheme misconcieved.
