winform 窗体最大化事件

protected override void WndProc(ref Message m)
        {
            FormWindowState previousWindowState = this.WindowState;

            base.WndProc(ref m);

            FormWindowState currentWindowState = this.WindowState;

            if (previousWindowState != currentWindowState && currentWindowState == FormWindowState.Maximized)
            {
                // TODO: Do something the window has been maximized

            }
        }
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);
}//网上这个会出问题 应该是变量的问题

 

posted @ 2017-12-07 17:37  Restrain  阅读(4882)  评论(0编辑  收藏  举报