How to host a .NET MDI Child Window inside a VB6 MDI Application

D

Dave Caton

Hi folks,

a bit of a tricky problem to solve for you. I have a scenario where I have
a legacy VB6 MDI application that I want to act as a host for a MDI child
form that resides in a .NET assembly.

I can do the simple stuff such as exposing the .NET Form as a COM object and
registering the assembly for COM Interop, the issue is how can I force the
..NET Form to become a MDI child of the parent VB6 MDI Parent Window.

Any suggestions would be most welcome
 
S

Saurabh

Its difficult to have a clean implementation. You can use the SetParent API
to set the parent.

--Saurabh
 
D

Dave Caton

Hi Saurabh,

I've tried using the SetParent API - this half works as in the MDI child
window is constrained by the MDI parent, however the window does not draw
correctly (or position itself correctly) when minimised.

I suspect that I need to amend the control styles to set WS_CHILD in the MDI
child form, but this has not been successful as yet.

Any further advice would be appreciated,

Dave
 
H

Herfried K. Wagner [MVP]

* "Dave Caton said:
I've tried using the SetParent API - this half works as in the MDI child
window is constrained by the MDI parent, however the window does not draw
correctly (or position itself correctly) when minimised.

I suspect that I need to amend the control styles to set WS_CHILD in the MDI
child form, but this has not been successful as yet.

I doubt that you will find a stable solution. I would design the form
in VB6 instead of using a .NET form. Using .NET Windows Forms within
VB6 projects is IMO not recommended.
 
S

Saurabh

Herfried K. Wagner said:
I doubt that you will find a stable solution. I would design the form
in VB6 instead of using a .NET form. Using .NET Windows Forms within
VB6 projects is IMO not recommended.

Yes but there come certain situations when you have to do it. If lots of
people are migrating to .NET, they will add the new functionality using .NET
rather than migrating the whole existing application, so I suppose there
would be a lot of people trying to do that. Setting the styles and all those
things shouldn't be a problem, I suspect its the relationship issue, what I
mean is, you stuff .NET form into Win32 App so your form knows that its
parent is Win32 App but the Win32 app does not know about this new 'foster
kid'. I could be wrong but I think if we can manage to tell the Win32 App
about the 'foster kid' the heterogeneous mix of form may work smoothly.
 
S

Saurabh

Has anybody achieved this?
I have noticed one more thing, If I click on the MDI child form, the Main
MDI window still shows grey titlebar color (inactive) whereas for the native
MDI child window, the main application window activates itself !!
 

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