Solved

Disable Close Option on MDI Parent, Enable on Child

Posted on 2002-03-15
13
295 Views
Last Modified: 2010-05-02
I'm trying to make a menu editor that functions similar to the way that MS Office apps do.  I have a File/Close menu option in the MDI application, but I can't figure out how to code it.  

If the user clicks close (or uses the shortcut) I want to close the MDI child that has focus.  And, I want the close option to be disabled if the MDI parent is the only thing open.

Right now, the close option is enabled on all forms (both parent and child).  Also, if I put an Unload Me in the Click event of mnuClose, the MDI parent unloads, thereby unloading the application - rather than unloading the child form that has focus.
0
Comment
Question by:cnealy
  • 8
  • 5
13 Comments
 

Expert Comment

by:bill02
ID: 6869462
all you need is this code


Unload ActiveForm

or if its on a button thats not on the mdi form then

unload MDIForm.Activeform

that should do it
0
 
LVL 1

Author Comment

by:cnealy
ID: 6869472
Great!  Unload ActiveForm Worked.

Now ... how do I disable the Close menu option if the MDI parent is the only form that's loaded?
0
 
LVL 1

Author Comment

by:cnealy
ID: 6869477
Great!  Unload ActiveForm Worked.

Now ... how do I disable the Close menu option if the MDI parent is the only form that's loaded?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Expert Comment

by:bill02
ID: 6869493
If ActiveForm Is Nothing Then
disable button
End If
that should be all you need to do
0
 
LVL 1

Author Comment

by:cnealy
ID: 6869503
Where do I put the code?
0
 
LVL 1

Author Comment

by:cnealy
ID: 6878208
Bill - when you explain where to put the code, I can accept your answer.  
0
 

Expert Comment

by:bill02
ID: 6878671
when do you want the button to be unabled you could put them on child form close you could put them on form load form initialize when do you want it to become enabled put the code there
0
 
LVL 1

Author Comment

by:cnealy
ID: 6878783
I want the close button to be enabled only when the MDI parent is the only form that is loaded.  So, I'm still unclear on where to put it.   I tried putting it in the MDI Parent's Activate event, but that event only fires once when the application is initially loaded.

Any details (code examples)  you can provide would be great.

Thanks.
0
 

Accepted Solution

by:
bill02 earned 50 total points
ID: 6878846
on child form unload
button.enabled = false
on child forms gotfocus
button.enabled = true
on mdiform load
If ActiveForm Is Nothing Then
button.enabled = false
End If
this is the easiest way there is another that im not to sure of thats the link mode on mdi and child forms you could set the links and when a link closes check to see if activeform but im not sure how that works
0
 
LVL 1

Author Comment

by:cnealy
ID: 6878883
Does this mean that I'll need to code Unload and GotFocus events on every child form one by one?  I have about 25 forms, so this will take awhile.  Can you think of any other way that I can determine if the MDI parent form is the only form that's open?  Unfortunately, I don't see a GotFocus event for the MDI parent ....
0
 
LVL 1

Author Comment

by:cnealy
ID: 6878886
Does this mean that I'll need to code Unload and GotFocus events on every child form one by one?  I have about 25 forms, so this will take awhile.  Can you think of any other way that I can determine if the MDI parent form is the only form that's open?  Unfortunately, I don't see a GotFocus event for the MDI parent ....
0
 

Expert Comment

by:bill02
ID: 6878895
yes i know that is the problem i was running into to see if the mdi form has focus im not sure how to obtain that the only way i know how to do it is put it on every form
0
 
LVL 1

Author Comment

by:cnealy
ID: 6878918
Thanks, Bill02.  
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

809 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