Minimize up the chain to the Parent Form

QuestionI have windows application in which the user has the ability to edit data in a modal dialog(1). During that time other modal dialogs (2) may spring up for the first modal window (1). The behavior I see is that if the any of the childmodal windows (2 | 3) are minimized, that there direct parents (1 | 2) are not minimized as well.

How can one move the minimize message up the chain of command?


WHYThere are circumstances where the minimize of the modal child is needed and the user wants to view the parent, but there are also other times when all items need minimizing.

Platform
  • .Net 2
  • C#
  • The first modal dialog (2) has its owner property set the the main form.

advTHANKSance
[1039 byte] By [OmegaMan] at [2007-12-29]
# 1
You might have noticed that code like this has unexpected results:

private void Form3_Resize(object sender, EventArgs e) {
if (this.WindowState == FormWindowState.Minimized) {
Form frm = this;
while ((frm = frm.Owner) != null)
frm.WindowState = FormWindowState.Minimized;
}
}

The problem is that when you minimize a dialog, the app will no longer have any window left that can receive the focus. Windows needs to find another window to give the focus. None of your app's windows qualify, your app will disappear behind some other app's window.

Dialogs should not be allowed to be minimized, set their MinimizeBox property to False. Take a good look at your UI and ask yourself if you really need a dialog. Simply writing an event handler for the popup window's FormClosed event is usually all you need.

nobugz at 2007-9-4 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
Hi Hans,

I think you see the dilemma faced. If the user has the intentions of minimizing the process to view other items not related to the process or even to get to the desktop, the minimize button is localized to the window being used. Since it is modal, going to the main window's form fails, for focus is in the top most modal dialog.

Note the only way to do this is to use the Show Desktop in the system tray which will minimize all applications and their modal dialogs. Maybe that 's the hint...

Take a good look at your UI and ask yourself if you really need a dialog.

Ahh I wish life was that easy <g>...unfortunately I am architecting/implementing a major data migration between two disparate financial systems. The tool I am writing is to generate a set of data driven rules for the migration and to view the application of the rules against the initial database and its target database.

The first dialog in question holds a non-bounded DataGridView which allows the user to defines a specific migration tasks. In that view, or the row containing the task are fill in data areas and two buttons which bring up an edit box for task specfic SQL and the other button brings up another DataGridView which allows the specification of a column by column basis for data to be changed, by business rules, to be placed into the target migration system.

The alternative is to make the migration user place the migration specifications into a multi-level Xml which would be fraught with in-ease of use and other by hand complications.



Now this issue of the post is not a show stopper by any means. For it is a fully functioning application, click-once btw, that is used by the team to specify the rules for this large data migration and this is just a nuance when working with the application. I just thought I would throw it out to the community to see if there is a work around...besides clicking the Show Desktop icon.

Thanks for the response!

OmegaMan at 2007-9-4 > top of Msdn Tech,Windows Forms,Windows Forms General...