C#窗体最大化,最小化,关闭按钮事件捕获


const int WM_SYSCOMMAND = 0x112;
const int SC_CLOSE = 0xF060;
const int SC_MINIMIZE = 0xF020;
const int SC_MAXIMIZE = 0xF030;
protected override void WndProc(ref Message m)
{
    if (m.Msg == WM_SYSCOMMAND)
    {
        if (m.WParam.ToInt32() == SC_MINIMIZE)
        {
            this.Visible = false;
            return;
        }
    }
    base.WndProc(ref m);
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

验证码 * Time limit is exhausted. Please reload CAPTCHA.