[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Disable Close Option on MDI Parent, Enable on Child

Posted on 2002-03-15
13
Medium Priority
?
309 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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

591 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