Jeremy Thompson Jeremy Thompson - 11 months ago 41 Question

Contain a VB6 form in a .Net MDI

I'm porting an old VB6 app into .Net but one Vb6 form is too big to migrate in this release.

I Shell the Vb6 exe to show the VB6 form from .Net, but the VB6 form is not contained in the .Net MDI. I have a gut feeling its not possible to embed the VB6 form in the .NET MDI, does anyone know if this is possible?

I'm after something like Interop Forms Toolkit 2.1 or even an API

Answer Source

It is indeed possible. It's just neither simple, nor a particularly a good idea...

You'll need to create an ActiveX container for the form, which you can then embed the VB 6 form into. See this article on CodeProject for details: Embedding of VB6 form in .NET applications

Another possible (and significantly simpler approach) might be to set the parent of your VB 6 form as the .NET MDI container. I'm not actually sure if this will work (I've never tried it), but it's worth a shot. You'll need to P/Invoke the FindWindow function to get the handle to your VB 6 form window, as well as the SetParent function to change its parent window.