We are currently working on porting an old VB6 application to WPF. The plan, in phase one, is to port several key forms and not all the application. Its been brought up that we might try and open some of the old VB6 form from within the WPF application (as modal forms), thus providing greater functionality then intended for the first phase.
My question for you friends, first of all, is this kind of abomination 🙂 even possible? Can VB6 forms can be opened from a WPF application?
Thanks, Shahaf.
What you need to do is package the forms into an ActiveX DLL and expose classes that can setup the initial values, bring up the forms, and return whatever values they modify.
For example in my own CAD/CAM applications we have the Forms, then a layer that consists nothing of Command Objects (classes that implement the Command Design Pattern) that modify the model, and the model all written in VB6.
Some of the Commands call dialogs that are VB6 Forms. Some are simple and other are complex. The first phase of our conversion project was to rip off the top form layer and replace it with a .NET equivalent. The new .NET forms referenced the Active DLLs containing the Command Object.
It worked fine. There were some visual differences between the .NET look and the look of a VB6 form but other than the command dialogs ran just as they did under the VB6 executable.
One note of caution is that if you are continuing to modify the original ActiveX DLLs during this process then building the .NET program becomes a bit of pain. Unlike VB6, .NET isn’t as automatic when it comes to updated references to newer versions of a referenced ActiveX library. The solution is simple, you drop the original reference and then add the new reference.