COM interop

G

Guest

I have a .net class that displays a .net form (1), when the user clicks a
button on the form (1) an event is fired that is captured by a wrapping COM
dll. The COM DLL instantiates another COM Class that shows a form (2). The
wrapping COM object is written in VB classic and the called COM object that
shows the form (2) should show it as application Modal ie myform.Show
vbModal. The thing is it does not, THE FORM(2) IS shwon for all VB forms as
modal, but for .net forms the form(1) is left free.

I thought I may be able to set the parent form when showing, I can get the
form (1) hwnd, but I need a VB form object to pass to COM form (2) .show
method. Any ideas?

Or is there any other way around this?
 
T

TDC

Well, you can definately set a form's parent via the API using hwnd,
but that won't give you all of the behaviors you want.

Here's one work-around:

When the .NET form button_click is fired, show a dummy .NET form
modally (ShowDialog). This form should then invoke your VB form. The
dummy form should be made effictively hidden (no titlebar, width and
height of 0 or 1, etc), and the VB form may need to use an API to set
the modal .NET form as a parent so that the VB modal forms stack
correctly on top of the .NET forms.

HTH,
Tom
 
G

Guest

Thanks TDC,

Any suggestions as to the API function to get it to stack? SetParent()
doesn't seem work because it displays it as MDI style.

Ade
 
T

TDC

Hmmm....

Well it's really the owner that needs to be set, not the parent. And
the owner is set under the covers in a call to CreateWindow or
CreateWindowEx.

You'd have to get pretty low-level to try to make a .NET form an owner,
and I'm not sure that it is even possible. (The only way I could think
is to hook the creation messgae and modify the owner window, but I
don't even know if that would work. Kind of beyond my knowledge set).
 

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