we have a little problem with calling a vb6 form modal on a a vb.net form.
We have a startup exe with a form at first.
On this form the user can open subprojects. Each subproject was called in an own thread. So the user can toggle between the other subprojects and modal windows on subprojects don't lock the other windows.
Now we want to call a VB6 ActiveX DLL/EXE out of the subproject.
In this VB6 DLL/EXE we call a function which opens a VB6 form modal. If the VB6 component is a DLL the menuform seems to be the owner of the VB6 window. Other subprojects are not locked. But when the VB6 component is a EXE the subproject is the owner. That looks good on first view. But if you call two VB6 EXE from two different subprojects, the last one locks all previuos.
How is it possible to call a VB6ActiveX DLL/EXE -form modal out of VB.NET that was only modal to the calling form.
I have added a sample to eximplify here -> Sample
BjörnThursday, October 02, 2008 12:11 PM
Based on your post, my understanding of your issue is that you call ActiveX component to show a VB6 form and you want to implement the above requirement.
As far as I know, a modal form or dialog box must be closed or hidden before you can continue working with the rest of the application. In Windows Form project, you can implement the similar effect with the Owner property, I think that you need to modify your application to use this feature to satisfy your requirement. Hope this helps. If you have any further issues, feel free to tell us.
Dim f As New Form2 f.Owner = Me f.Show()
Please remember to mark the replies as answers if they help and unmark them if they provide no help.Tuesday, October 07, 2008 2:07 AM
first thank you for your reply.
The problem is that we call the vb6 form not directly in vb.net, but call a vb6 class which opens the vb6 form:
'VB6 class/method called from vb.net Public Sub OpenForm(text As String) Dim lForm As New Form2 lForm.Caption = text lForm.Show vbModal Unload lForm End Sub
When i try to pass the vb.net form i get a typemismatch :
'VB6 class/method called from vb.net Public Sub OpenForm(vbnetForm as object, text As String) Dim lForm As New Form2 lForm.Caption = text lForm.Show vbModal, vbnetForm Unload lForm End Sub
As you can see in my sample its a very curious behaviour calling a vb6 form in vbnet.
Looking forward to your reply,
Tuesday, October 07, 2008 6:54 AM
- Edited by moellerbj Tuesday, October 07, 2008 6:56 AM Added the sample link
Of course we can't pass the .NET form object as the VB6 Form object. If you use Interop Form toolkit to create the Interop Form in this scenario, try it to see whether it satisfies your requirement.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.Wednesday, October 08, 2008 12:25 PM
It may be a silly suggestion but have you tried treating your form as a dialog and modifying your code simply to be
instead of lform. show vbModal
This would effectively display the form in a modal fashion as the dialog box must be closed before the application can continue
TrisThursday, October 16, 2008 11:03 AM
I didn't fully explain my thinking - have a look at this article
Or maybe I completely misunderstand your intent?Tuesday, November 04, 2008 1:55 PM
I wanna know the owner of an interops form too.
A .NET Windows Form called by a VB6 form like this:
Unfortunately interops forms library doesn't have the second parameter of the Show method
Would it be nice if we can do this in the .Net Form for example:
Me.Owner.Top = 10
Has anyone have a way to do this?Monday, March 21, 2011 8:26 PM
So one way that this can be done is to have an event on your .NET form. Raise that event from the .NET form and implement that event in your VB6 form. Your VB6 form can then call whatever.
You cannot have a .NET Form set as VbModal do anything back in VB6 as that process is isolated. You can fake it by setting the ZOrder of the .NET form in VB6 when a click, double-click, or focus event is executed. Unfortunately, a VB6 form doesn't have a "focus" event.
Microsoft MVP, ASPInsider
Tuesday, November 22, 2011 9:41 PM
- Proposed as answer by Jason N. GaylordMVP Tuesday, November 22, 2011 9:42 PM
I know this is a really old thread, and you may be thinking "Why would you be doing that NOW - in 2012!?!". But here we are. I too need to interop a number of Vb6 Modal Forms that are called through a public object in a dll.
Our application also has multiple UI threads (one per module) as described by your post and we are experiencing the same issue when calling the methods in the dll to show the forms. Fine when called from the main Module, but on the sub-modules the modal forms fall to the back and appear to attach themselves to the Main module's form.
So did you ever, resolve the issue of setting the owner of the Vb6 Modal form to a .Net parent?
Interestingly, when showing a modal form from a class in an OCX (rather than a dll), there is no such issue, the owner is resolved successfully (which gives me some hope). I know one solution is to recompile each dll (of which there are many) as ocxs, but this would been rebuilding a large chunk of the Vb6 code base, which is large and we have no automated build routines!
Y CymroThursday, June 21, 2012 2:43 PM