Solved

VB6: One MDI form instance limitation

Posted on 2004-04-20
7
1,371 Views
Last Modified: 2012-05-04
I have a fairly complex project and need to instantiate more than one instance of the same MDI form at runtime. Is there any way to do this? The following works for SDI only.

Dim i As Integer
Dim frm As frmExplorer

For i = 1 to 5
    Set frm = New frmExplorer
    Call frm.Show
    Set frm = Nothing
Next
0
Comment
Question by:dnhughes
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 49

Assisted Solution

by:Ryan Chong
Ryan Chong earned 63 total points
ID: 10871344
There is only allow one instance of MDI form, you can create more that one instance of it..
0
 
LVL 6

Expert Comment

by:LunaSkye
ID: 10871386
Are you trying to make more than one instance of the parent MDI form? Or of a child?

I just tried this code..

'This is the load procedure for the PARENT mdi form
Private Sub MDIForm_Load()
    Dim Frm1 As frmTEST
    Dim Frm2 As frmTEST
   
    Set Frm1 = New frmTEST
    Set Frm2 = New frmTEST
   
    Frm1.Show
    Frm2.Show
End Sub


I end up wtih 2 of the same form sitting as children in the mdi parent form..

Is this what you want?
-Andrew
0
 

Author Comment

by:dnhughes
ID: 10871646
ryancys
  How?

LunaSkye
  I'm trying to create multiple parent MDI forms
Private Sub cmdCreateWindows_Click()
    Dim frmMDI1 As frmMDITEST
    Dim frmMDI2 As frmMDITEST
   
    Set frmMDI1 = New frmMDITEST
    Set frmMDI2 = New frmMDITEST
   
    frmMDI1 .Show
    frmMDI2 .Show
End Sub
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:dnhughes
ID: 10871913
The error that I'm getting is when I try to create a second instance is:
Run-time error '426':

Only one MDI Form allowed
0
 
LVL 6

Accepted Solution

by:
LunaSkye earned 62 total points
ID: 10872095
DNHughes

This quote comes from VB Help:

"An application can have only one MDIForm object but many MDI child forms."

Maybe you could have multiple instances of your application?  or somehow move your functionality onto a child form?

Sorry im so general, i dont have alot of specifics to go on.

-andrew
0
 
LVL 4

Expert Comment

by:SSSoftware
ID: 10872962
For your information

I think
VB.Net allows multiple MDI Parents in an application.

Ed
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 10875943
>>There is only allow one instance of MDI form, you can create more that one instance of it..
typo, sorry, shoud be:
There is only allow one instance of MDI form, you can't create more that one instance of it..

SSSoftware is right, create multiple MDI form is allowed in vb.net, example:

Dim f As MDIForm = New MDIForm()
        f.Show()
        f.focus()
        f.BringToFront()
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now