Solved

MDI parent problem

Posted on 2002-04-04
6
180 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protecting vb6 & .Net code Obfuscation 18 127
Help me. 3 57
Not seen Link button 5 41
Problem to App 4 83
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable 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 viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

825 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