Solved

MDI parent problem

Posted on 2002-04-04
6
179 Views
Last Modified: 2013-11-13
I have an imagelist and winsock control located on the MDI parent form which I want to access from the child forms.

the MDI parent is named frmMain...

However when I try to access the imagelist for example via

' In child form
Set imgWebsite.Picture = frmMain.ImageList1.ListImages("website_0").Picture

It's trying to create a new MDI form and gives me the "Only one MDI Form Allowed" error.

I don't want more than one opened, I'm not declaring it to open.  I've had a similar problem before but can't remember how I got around it.

Any suggestions?
0
Comment
Question by:ketapillar
  • 2
  • 2
  • 2
6 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6918808
Have you created an instance of your MDI parent (dim x as new frmMain)? In this case, you have to use x everywhere instead of frmMain.
0
 
LVL 3

Author Comment

by:ketapillar
ID: 6918829
I did in the StartUp.bas:Sub Main

----
  Dim fMain As New frmMain
  fMain.Show
----

How would I use the fMain in the frmChild? It's not a public var.
0
 
LVL 3

Author Comment

by:ketapillar
ID: 6918857
I did in the StartUp.bas:Sub Main

----
  Dim fMain As New frmMain
  fMain.Show
----

How would I use the fMain in the frmChild? It's not a public var.
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.

 
LVL 69

Accepted Solution

by:
Éric Moreau earned 100 total points
ID: 6919022
you have to declare it as Public in a Standard module or do not use fMain at all.

Simply replace:
 Dim fMain As New frmMain
 fMain.Show

With:
 frmMain.Show

This way, you will be able to use frmMain everywhere in your app.
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6919092
You might also be able to say:

Set imgWebsite.Picture = Me.Parent.ImageList1.ListImages("website_0").Picture

Or

Set imgWebsite.Picture = Me.ParentForm.ImageList1.ListImages("website_0").Picture

(I forget which is the correct property)
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6919104
Or, you can do it the other way around, so, assuming that the code that creates the mdi child forms is actually in the mdi parent form:


Code in MDI Parent:
Dim X as New frmChild ' assuming this is the name of an mdi child style form

Load X
Set x.imgWebsite.Picture = ImageList1.ListImages("website_0").Picture

or, this might not require a Set statement:

x.imgWebsite.Picture = ImageList1.ListImages("website_0").Picture

x.Show
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

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This video teaches viewers about errors in exception handling.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

895 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

12 Experts available now in Live!

Get 1:1 Help Now