all groups > dotnet interop > december 2005 >
You're in the

dotnet interop

group:

exposing a hWnd in a wrapper class for Windows.Form


exposing a hWnd in a wrapper class for Windows.Form Graham Charles
12/30/2005 1:09:36 AM
dotnet interop:
I've got an ActiveX container control that claims to be able to host
Windows Forms windows. Here's the extent of the documentation:

It is also possible to use windows that are not created
using Visual Basic [6]... by creating a wrapper class. This
class must be a standard COM class that implements
the IDispatch interface, and exposes one property with
the name "hWnd".

So I created a wrapper class in vb.net, registered it for Interop, and
implemented an hWnd property. The control functions correctly, but
doesn't display the window; I expect that's because of .net's constant
changing of the window handle? Or perhaps I'm not implementing
IDispatch right (but doesn't that get handled by the interop?).

Any ideas would be appreciated. The host control is Innovasys
DockStudioXP 2.

Thanks!
Re: exposing a hWnd in a wrapper class for Windows.Form Graham Charles
1/3/2006 2:06:29 AM
Thanks for your thoughts. Naturally, I'd already contacted Innovasys,
but their poor support reputation is unfortunately deserved: they
frequently don't respond to developer requests, as a rule. Pity, since
their products are generally pretty strong.

However, I was able to implement this functionality --- a Windows Form
seamlessly running inside an ActiveX control! The trick lay in using
the FindWindow API (rather than the .Handle.ToInt32 property) to get
the window handle.

I've been looking for a good treatment of handles to S.W.F.Control and
..Form, but haven't found anything yet. If you know of a good
whitepaper, I'd sure appreciate it.

g.
RE: exposing a hWnd in a wrapper class for Windows.Form v-phuang NO[at]SPAM online.microsoft.com (
1/3/2006 7:59:56 AM
Hi Graham,

Based on my knowledge, this heavily depended on the how the ActiveX
container control(Innovasys DockStudioXP 2) is implemented.
I think you would better contact the control developer or ask them for a
sample about the behavior.
DockStudioXP - ActiveX (.NET Ready) - V2.0
http://www.componentsource.com/catalog.asp?SC=CS&option=10661&PO=512950&ul=e
n&vw=T18

Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Re: exposing a hWnd in a wrapper class for Windows.Form v-phuang NO[at]SPAM online.microsoft.com (
1/4/2006 3:48:01 AM
Hi

I think this is related with how the activeX control is implemented.
Also the form's handle maybe differ when your close and reopen it.
So the FindWindow may be an workaround.

Common the Winform in .NET have a property handle which is inherited from
control.
But the concrete implement is not public.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button