Solved

MDI parent problem

Posted on 2002-04-04
6
178 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

744 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

13 Experts available now in Live!

Get 1:1 Help Now