Hi,
I have a Enertrprise MDI form written in VB 2005. This Enterprise MDI form, calls child forms are also in VB 2005, but are dll's with a gui interface.
I have a customer support MDI form which is in VB6. This Customer Support MDI form needs to call the vb2005 child forms, and pass parameters to it. After the child form is closed, the parent MDI (written in VB6) needs to be refreshed.
Is my best option to write a CCW
I am concerned about how to refresh the VB6 MDI form, after the child vb2005 form has closed (or for that matter, pass other information back to the VB MDI form).
Any detailed advice is appreciated

COM Interop question
KaiserSozeTR
I have a few quick questions.
- Can the UserControl communicate with the VB6 MDI form (as in pass back parameters or data values or setfocus back to the VB6 MDI form)
- Everytime I create a gui dll in VB.Net, which communicates with the VB.net MDI form, I need to copy that code and insert it into the UserControl project communicates with the VB6 MDI
same process involved with making updates, references to 3rd party components, or any modifications to the dll code
Is there any way to tie the two together so I am not doing it twice
- We currently have a customized project template. If I open up my customized project template, is it possible to integrate
the UserControl template into my project template, display it as a project in the solution window, so we arent maintaining two
project templates If so, would there be a problem when doing a build or in production mode
Thanks
roychoo
Sorry I was signed in on my non-MS account, that last reply's from me.
Thanks,
Jonathan
helpmeplz
Yep you've got it, just put the controls and logic on an Interop UserControl and then place this control on a VB6 MDI child form (either at design time through the Toolbox or at run time using a VBControlExtender).
Hope that helps,
Jonathan
Puzzl3b0x
You need to reference the .tlb, not the .dll. When you build your Interop UserControl it automatically registers itself as a COM component, and creates an InteropUserControl.tlb file in your bin directory.
All you need to do in VB6 is click Project->References and select the name of your control library (you'll see the file location as "C:\windows\system32\mscoree.dll" - this is the file the CLR uses to load the control into VB6).
If you followed those steps are still seeing an error then it might be related to a bug we have a fix for, if you want to try out an updated template you can email me directly at jonathanDOTanejaATmicrosoft.NOSPAMcom.
Jonathan
BrentB
Hi John,
Thanks for the info. This does help. Though I want to know if this version supports the VB6 MDI form In which case, I can enclose my VB2005 GUI child form dlls into this control, and add it to my VB6 toolbox. The VB6 MDI form will then be able trigger the GUI child form dll. Am I correct here
Thanks again.
Scuzzy
Ok. How do I actually "wrap" the GUI dll into this wrapper
Can you describe the steps
And then, the InteropUser Control is looking for "$safeprojectname$.ClassId, $safeprojectname$.InterfaceId, $safeprojectname$.EventsId" values.
How do I get assign values to the UserControl
Thanks
lwfoon
The reason you're seeing $safeprojectname$ is the project was opened directly instead of as a template. What you need to is drop the InteropUserControl.zip file in your My Documents\Visual STudio 2005\Templates\Project Templates\Visual Basic\ folder, then click File-New Project and select "VB6 Interop UserControl".
Once you've done that, you basically just need to copy and paste your controls from your Form on to your UserControl, and copy the code underneath. Once you build the control, you can add it in VB6 and drop it on an MDI child form (and size it to fill the entire form if you want).
Jonathan
Herru Perdana
I've been following the previous threads to find a similair problem using Interop. I have a couple additional questions I'm hoping someobe can answer for me.
I have created a small VB.NET form that I wish to include in our existing VB6 application. I have referenced the .tlb, but am a little confused on how to "draw" that .NET control on a VB6 form. I had to create a new instance of the form and show it, but leads to my next question on how do I pass values back and forth. I have a public variable on the .NET form, but not sure if it is in the right place. I can see it within the intellisence when referencing the variable, but having problems referencing it on the .NET form itself.
If I could get a sequence of things that need to be completed to create a simple .NET form that communicates with VB6, that would be a great help!
Thanks!
ivanbolcina
One option you could look at is the Interop UserControl template we've posted on our team blog (we'll be launching the finished version of this in the near future). What you could do with this is copy your VB2005 MDI Child forms on to an Interop UserControl, then host the Interop UserControl in VB6.
http://blogs.msdn.com/vbteam/archive/2006/11/02/interop-roadmap-usercontrols-mdi-and-data.aspx
Hope that helps,
Jonathan
DiasVFX
bit confusing, but very helpful.
The problem I might be facing is that the GUI dlls have been created as windows Forms, and converting those to UserControls might be out of scope at this point of the project.
Putting all the logic on a .Net UserControl, and hosting the .Net UserControl on the .Net MDI form and the InteropUserControl. makes perfect sense.
I created a dummy vb6 MDI project and attempted to add a reference of a barebones "InteropUserControlTest.dll" but I got a message saying "can't add a reference to the specified file". How can I call the "InteropUserControlTest.dll" from the VB6 MDI
Thanks.
LukeBMS
1. Yes, you can pass data back and forth between the two. Any property, method, or event you make public will be visible to VB6 (to keep it simple I'd only recommend passing Strings, Integers, and Booleans across, but you can marshal other types as well). Make sure any new public members you add are at the bottom of the class.
For setting focus specifically you'd have to do it through an event, then have VB6 code set the focus (since the .NET control can't see any of the VB6 controls).
2. The easiest thing to do is put *all* your logic on a regular .NET UserControl, then use this UserControl on your VB.NET MDI form and also on your Interop UserControl. You could actually host your Interop UserControl on your VB.NET MDI form directly but I think it's better to introduce a layer of abstraction and use a regular .NET UserControl here.
3. It's definitely possible, but without knowing the specifics of what your template does it's tough to say how easy it will be. What I'd suggest doing is modifying the UserControl template to include whatever stuff you have in yours (don't try to modify your template to do what the UserControl template is doing).
The main things you'll need to ensure in your hybrid template are:
a. That the file ActiveXControlHelpers.vb is included
b. Each Interop UserControl has the ComClass attribute
c. The "Register for COM Interop" checkbox on the My Project\Compile tab option is checked
d. The GUIDs generated in InteropUserControl.vb and My Project\AssemblyInfo.vb are all unique.
We'll be offering full phone support for the UserControl template soon, but modifying the template would not be a supported scenario.
To summarize, I'd recommend having all your logic on a regular .NET UserControl, and hosting that on both the VB.NET MDI form and the Interop UserControl. That way any changes you make only need to be made once.
Hope that helps,
Jonathan