I am working on an app that is an MDI. When the user clicks a button on an MDI child, I want to "disable" the current MDI child (and only the current child window), open a new window that has control, and then re-enable the child window when the new window is closed...very similar to using showDialog().

The thing I an having trouble figuring out is how to allow the other child windows to be active at the same time as when the new window is open. If I use the showDialog(), all child windows are disabled.

Any suggestions on how to do this would be greatly appreciated.

Recommended Answers

All 8 Replies

Set the Form.Enabled to false, show the dialog, when it returns, set the FormEnabled to true.

lets assume you have a button on the current child window(form1) named 'button1' and you have a form (control) named 'form2' you want to display while the current child window is disabled.

under the button1;

me.enabled = false 
form1.show

when you are through with your control form, there should be a button to close it
and take you back to your child window, lets call it 'btnClose'

under btnclose;

me.dispose 
form1.enabled =true

These seem to be getting me partially there. However, when I click the button on the MDI child window, the MDI child window is disabled and the popup window is displayed as expected. When I attempt to open another MDI child while the popup is still showing, the popup always remains on top (topmost is set to false...I already looked at that) and I can't seem to do anything to get the new MDI child in front of it.

so what exactly do you want? do you want the MDI Child not to be displayed at all? If
you dont want the pop-up to show when you open other windows, then you have to open the
pop up as a dialog. this would make you respond to the pop up and close it before you can move to any other window.
In other words, use

me.dispose 
form1.showdialog

Here are some specifics. The user selects a family to maintenance and a form opens with that family's information (refer to as “Family 1 window”). The user can select a second family and a second form opens with that family's information (refer to as “Family 2 window”). The user can click a button on “Family 1 window” which will open a new window (refer to as "Family 1A window”) where they can enter additional information about Family 1. When this button is clicked, “Family 1 window” should be visible but disabled and “Family 1A window” should be enabled. “Family 2 window” should still be enabled. They should also still be able to open another Family such as Family 3. At this point, “Family 1 window” is visible but disabled, “Family 1A window” is enabled, “Family 2 window” is enabled, “Family 3 window” is enabled. When the user closes “Family 1A window”, “Family 1 window” should be enabled.

So far I have gotten “Family 1A window” to open and “Family 1 window” to disable and “Family 1 window” to enable when “Family 1A window” is closed. However, when “Family 1A window” is displayed and I try to bring “Family 2 window” to the top, “Family 1A window” is still on top of “Family 2 window”.

From my additional testing, it appears that it has something to do the fact that the “Family x window” is an MDI child and “Family xA window” is a normal window and not an MDI child and normal windows are always on top of MDI children windows. To get around this, I have made the “Family xA window” an MDI child and using variables, have linked the two together so when the “Family 1A window” closes, the program enables the “Family 1 window”.

Is there a better way that I just haven’t stumbled over yet?

you did not get a good algorithm from the start. let me give you a description:
1. First, have an MDI Parent window which would serve as your main form
2. add a tool strip to the main form(MDI)
3. add a new form and call it your familyA
4. add a tool strip or menu strip to the FamilyA form and label the drop down menus accordingly
5. add a new form (this should be familyA1 to add additional information) and should be called up from within FamilyA.
6. repeat steps 3 to 5 to create as many more forms and subsections as you wish

NOTE: all other forms excluding MDI Parent should be set as an MDI child to the MDI parent

So the "Family x window" and "Family xA window" should both be MDI child windows of the same parent...or did I misunderstand? If so, that is what I have done but it seems like there should be a was to tie "Family xA window" directly to "Family x window" like a parent / child relationship instead of making them equal.

yes. you can have only one MDI Parent in a project. just call up Family Xa from
FamilyX but both are MDI child of the main form (MDI Parent)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.