Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MDI parent problem

Posted on 2002-04-04
6
Medium Priority
?
185 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 70

Accepted Solution

by:
Éric Moreau earned 400 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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
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 tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

886 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