Solved

MDI parent problem

Posted on 2002-04-04
6
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 70

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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 70

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

623 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