通过最大化按钮调整表单大小时,是否不会触发ResizeEnd事件? [英] ResizeEnd event is not triggered when resizing the form by maximize button?

查看:130
本文介绍了通过最大化按钮调整表单大小时,是否不会触发ResizeEnd事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,通过拖动边角来调整窗体大小时会触发ResizeEnd事件,但是当我单击最大化"按钮时将不会触发该事件.

In my application the ResizeEnd event is triggered when resizing the form by dragging the corners, but it will not be triggered when I click the maximize button.

Resize事件在我的情况下不起作用,因此我需要使用ResizeEnd事件.

The Resize event does not work in my scenario so I need to use ResizeEnd event.

为什么通过最大化按钮调整表单大小时未触发此事件?还是有人可以建议替代方案?

Why is this event not triggered while resizing the form by maximize button? Or can anyone suggest alternatives?

推荐答案

The ResizeEnd event is raised when the user finishes resizing a form, typically by dragging one of the borders or the sizing grip located on the lower-right corner of the form, and then releasing it. It also is raised when the user moves a form.

如果出于任何原因需要最大化窗口,从而引发ResizeEnd事件,则可以通过以下方式引发事件:

If for any reason you need maximizing the window cause raising the ResizeEnd event you can raise the event this way:

const int WM_SYSCOMMAND = 0x0112;
const int SC_MAXIMIZE = 0xF030;
protected override void WndProc(ref Message m)
{
    base.WndProc(ref m);
    if (m.Msg == WM_SYSCOMMAND) 
    {
        if (m.WParam == (IntPtr)SC_MAXIMIZE) 
        {
            //the window has been maximized
            this.OnResizeEnd(EventArgs.Empty);
        }
    }
}

注意

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