Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to create an MDI form in an ActiveX .exe (VB 6.0)

Status
Not open for further replies.

micha12

Programmer
Dec 11, 2002
10
RU
Hello everybody,

I created an ActiveX .exe project using Visual Basic 6.0. In this project I have added an MDI parent form.

I have a class in my project named CMain. This is the main class. In order to create my application from, for example, Excel, one should use the following code:

Dim Main As New MyActiveXEXE.CMain

In my project, in the Initialize event of the CMain class I have added the code:

Set MDIForm = New frmMDIParent

MDIForm here is a member of the CMain class. When an instance of the class CMain is created, a new MDI parent form should be shown, this was my idea. But when in Excel I try to create a CMain class object, Visual Basic would not allow me to create an MDIParent form, saying "Only one MDI form allowed". The problem goes away only if instead of writing Set MDIForm = New frmMDIParent I just write Load frmMDIParent. But in this case I get only one copy of a parent MDI form, irrespective of the number of CMain objects I created.

So I want a simple thing: I want an ActiveX .exe with a parent MDI form, so that when in Excel I write Dim Main As New MyActiveXEXE.CMain I get as many parent MDI forms as I wish.

Please, help me.

P. S. There is one another interesting thing I have discovered. In an ActiveX .exe, variables that are situated in a simple module are SHARED between all instances of the class (CMain in my example). If you don't know that, strange errors appear!
 
>>P. S. There is one another interesting thing I have discovered. In an ActiveX .exe, variables that are situated in a simple module are SHARED between all instances of the class (CMain in my example). If you don't know that, strange errors appear!

This is not so strange, since there's actually ony one instance of the module. And it does not only apply to ActiveX exes, it applies to all VB projects....


You can not show multiple MDI forms in a standard exe as well. So this is also not related to ActiveX.


Maybe to do what you want, you can set the instancing property of the class to Singleuse. This way, each time an instance is created, a new instance of the executable will be launched. Then you can have your multiple MDI forms. Only I don't know if these instances should be in anyway related to one another (which will be difficult in the case of multiple executables being launched).

Greetings,
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top