Windows Develop Bookmark and Share   
 index > Windows Forms General > Un-minimising midchild form - normal or maximised?
 

Un-minimising midchild form - normal or maximised?

I have a winforms application which has an mdi parent with several mdi child forms. I am allowing the user to minimise the child forms within the mdi parent. I am also forcing a maximum of 1 instance of each form to be open, so if the user tries to open a second instance of a form (mdi child), it will try to find an existing instance of that form, and bring that to the front. If the form is minimised at this point, I need to restore. This is where my problem is - how do I know if the child form should be normalised or maxmised?

Different users will have different preferences - some will work with the child forms maximised, some with it normalised, so when the minimised form is "un-minimised", it should match normal/maximised schema of the mdi parent. How do I determine what the current normal/maximised setting is for the mdi parent (as I beleive all mdi children are the same - either normal or maximised).

I hope this question made sense - feel free to ask questions if I made it all confusing.

fweeee  Sunday, December 07, 2008 6:08 AM
It is automatic. If the current MDI child form is maximized, a new MDI child form will automatically be maximized too, you don't need to help. Use this kind of pattern to restore any existing instance of a child:

Form2 mChild;

private void optionsToolStripMenuItem_Click(object sender, EventArgs e) {
if (mChild == null) {
mChild = new Form2();
mChild.MdiParent = this;
mChild.FormClosed += new FormClosedEventHandler(mChild_FormClosed);
}
mChild.WindowState = FormWindowState.Normal;
mChild.Show();
}

void mChild_FormClosed(object sender, FormClosedEventArgs e) {
mChild = null;
}

Note that the code sets WindowState to Normal. MDI will override this to Maximized if the current child is maximized.
nobugz  Sunday, December 07, 2008 6:18 PM
fweeee wrote:

I have a winforms application which has an mdi parent with several mdi child forms. I am allowing the user to minimise the child forms within the mdi parent. I am also forcing a maximum of 1 instance of each form to be open, so if the user tries to open a second instance of a form (mdi child), it will try to find an existing instance of that form, and bring that to the front. If the form is minimised at this point, I need to restore. This is where my problem is - how do I know if the child form should be normalised or maxmised?

Different users will have different preferences - some will work with the child forms maximised, some with it normalised, so when the minimised form is "un-minimised", it should match normal/maximised schema of the mdi parent. How do I determine what the current normal/maximised setting is for the mdi parent (as I beleive all mdi children are the same - either normal or maximised).

I hope this question made sense - feel free to ask questions if I made it all confusing.

There are several approaches. I would take the bull by the horns and create a List or Arrary of all of the child forms, for each user. Forms have a property called WindowState that tells you if the form is minimized or maximized. Check that property. Sorry for not posting any code, but I do not know what your code looks like.

Rudedog =8^D

Rudedog2  Sunday, December 07, 2008 4:31 PM
It is automatic. If the current MDI child form is maximized, a new MDI child form will automatically be maximized too, you don't need to help. Use this kind of pattern to restore any existing instance of a child:

Form2 mChild;

private void optionsToolStripMenuItem_Click(object sender, EventArgs e) {
if (mChild == null) {
mChild = new Form2();
mChild.MdiParent = this;
mChild.FormClosed += new FormClosedEventHandler(mChild_FormClosed);
}
mChild.WindowState = FormWindowState.Normal;
mChild.Show();
}

void mChild_FormClosed(object sender, FormClosedEventArgs e) {
mChild = null;
}

Note that the code sets WindowState to Normal. MDI will override this to Maximized if the current child is maximized.
nobugz  Sunday, December 07, 2008 6:18 PM

You can use google to search for other answers

Custom Search

More Threads

• How to detect if a Windows form is loaded
• new outlook email
• Switch window modal/not modal
• using events
• Active Directory
• Drag and Drop with Tree component
• Access methods from a scriptable app
• Problem trying to print with DefaultPageSettings.Landscape = true;
• C# Windows Application Detect Run Mode
• How to set the IME mode using C#?