Possible to attach an HWND to a Form??

  • Thread starter Thread starter WayneD
  • Start date Start date
W

WayneD

Hi All,
I'm writing a class that implements a COM interface. Unfortunately, one of
the methods passes in an HWND and I'm supposed to create a control with that
HWND as the parent. The idea is to plop my control onto the client's dialog.
Is this possible in C#??? There are 2 issues I'm concerned about:

1. What type of thingy should I create as the child control. I'm trying a
UserControl.
2. Is there some way to "attach" the HWND to a Form that I can then use to
set the Parent property of my newly created control?

I tried using Control.FromHandle, but that didn't work...

Thanks for any help!
Wayne
 
1. What type of thingy should I create as the child control. I'm trying a
UserControl.

Anything derived from Control should work.

2. Is there some way to "attach" the HWND to a Form that I can then use to
set the Parent property of my newly created control?

No, I think you'll have to call the SetParent Win32 API.



Mattias
 

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

Back
Top