WinForm 最大化、最小化、关闭按钮事件的拦截

private  int WM_SYSCOMMAND =  0x112;
private  long SC_MAXIMIZE =  0xF030;
private  long SC_MINIMIZE =  0xF020;
private  long SC_CLOSE =  0xF060;
protected  override  void WndProc( ref Message m)
{
     if (m.Msg == WM_SYSCOMMAND)
    {
         if (m.WParam.ToInt64() == SC_MAXIMIZE)
        {
             // MessageBox.Show("MAXIMIZE ");
             return;
        }
         if (m.WParam.ToInt64() == SC_MINIMIZE)
        {
             // MessageBox.Show("MINIMIZE ");
             return;
        }
         if (m.WParam.ToInt64() == SC_CLOSE)
        {
             // MessageBox.Show("CLOSE ");
             return;
        }
    }
     base.WndProc( ref m);
}

你可能感兴趣的:(WinForm)