Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working on Mdiforms, I took menustrip with one menustrip item(parent form), in that i took 3 child forms. when I open child forms those forms fit into parent form(child form maximize window). when i open childforms and close those child forms one by one there is no problem, all forms are maximized window size.

Problem:
When i open no.of childforms, the last childform is minimized the remaining childforms(before open last childforms) are goes to normal window size(not in maximum window size).

Question:
How to maximize Child windows, not only childforms closing, even childforms minimized also(all child forms are maximized only even closed or minimized).
Posted
Updated 27-Dec-11 21:48pm
v2

1 solution

You can for example create a helper class which would notify the child windows that some form has been minimized. For example something like the following.

Helper:
C#
public static class Helper {
    public static System.EventHandler SomeoneGotMinimized;

    public static void RaiseTheEvent() {
        if (SomeoneGotMinimized != null) {
            SomeoneGotMinimized(null, new EventArgs());
        }
    }
}

And in the child forms
C#
public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();

        Helper.SomeoneGotMinimized += new EventHandler(this.HandleMinimization);

    }

    private void Form1_Resize(object sender, EventArgs e) {
        if (this.WindowState == FormWindowState.Minimized) {
            Helper.RaiseTheEvent();
        }
    }
    private void HandleMinimization(object sender, EventArgs e) {
        if (this.WindowState == FormWindowState.Normal) {
            this.WindowState = FormWindowState.Maximized;
        }
    }
}

That's just a quick sketch so modify it based on your needs.

Note: this sounds like you're trying to emulate the SDI functionality so consider using SDI instead of MDI in your design. MDI is kind of 'abandoned' technique and is replaced by newer design guidelines.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900