Windows handles and windows forms

S

Steve Marsden

Hi

I want to specify the parent of a windows form to be a window handle I have
elsewhere in my project which is an unmanaged WIN32 handle. How can I do
this?

If I simple say myform->Parent=mainwnd (where mainwnd is a WIN32 handle) I
obviously get the error Cannort convert from HWND to
System::Windows::Forms::Control

Thanks
 
S

Steve Marsden

I had a further thought that I could use the WIN32 API function SetParent as
in

SetParent(myform->Handle,mainwnd);

but I get error

Cannot convert from System::IntPtr to HWND

How can I do this
 
S

Steve Marsden

Thanks Nish that did the trick.

I have further problem now that I have got past this.

In WIN32 programming if you create a child window on a top level window,
the child window cannot be activated when you click in it. All that happens
is the top level window is activated. This is the behaviour I want from my
Windows form child but this is not happening. The windows for can be
activated.

Is this beacuse I have just used SetParent on the Windows form to set its
parent to my main window or is it down to some property of of the Windows
form?

How can I stop a windows form child window from being activated

Thanks

Steve


Nishant S said:
Try using :-

(HWND)myform->Handle.ToPointer()

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com /* MVP tips tricks and essays web site */
http://blog.voidnish.com /* My blog on C++/CLI, MFC, Whidbey, CLR... */


Steve Marsden said:
I had a further thought that I could use the WIN32 API function SetParent as
in

SetParent(myform->Handle,mainwnd);

but I get error

Cannot convert from System::IntPtr to HWND

How can I do this
 

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