如何在子窗口最小化之前将子窗口设置为最大化 [英] how to set childwindows maximized, before child window minimized

查看:60
本文介绍了如何在子窗口最小化之前将子窗口设置为最大化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在Mdiforms上工作,我选择了带有一个menustrip项目(父表单)的menustrip,因为我选择了3个子表单.当我打开子窗体时,那些窗体适合父窗体(子窗体最大化窗口).当我打开子窗体并逐个关闭那些子窗体时,没有问题,所有窗体都最大化了窗口大小.

问题:
当我打开子窗体号时,最后一个子窗体被最小化,剩余​​的子窗体(在打开最后一个子窗体之前)将变为正常的窗口大小(而不是最大窗口大小).

问题:
如何最大化子窗口,不仅关闭子窗体,甚至最小化子窗体(所有子窗体也仅在关闭或最小化时才最大化).

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).

推荐答案

例如,您可以创建一个帮助程序类,它将通知子窗口某种形式的表格已被最小化.例如以下内容.

帮手:
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:
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

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;
        }
    }
}


那只是一个简单的草图,因此请根据您的需要进行修改.

注意:这听起来像是您在尝试模拟SDI功能,因此请考虑在设计中使用SDI而不是MDI. MDI是一种被遗弃"的技术,已被更新的设计指南所取代.


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.


这篇关于如何在子窗口最小化之前将子窗口设置为最大化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆