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

x
?
Solved

Disable Close Option on MDI Parent, Enable on Child

Posted on 2002-03-15
13
Medium Priority
?
306 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

782 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