protected override void WndProc(ref Message SystemMessage)
{
       if ((int)SystemMessage.Msg == 0x005)
       {
           if (((int)SystemMessage.WParam) == 1)//最小化
           {
                MessageBox.Show("最小化");
                return;
           }
        }
        else
        {
           base.WndProc(ref SystemMessage);
         }
 }如上   拦截系统消息   当窗体最小化时 弹出 “MessageBox.Show("最小化")” 了   但为什么窗体还是最小化了???

解决方案 »

  1.   

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

  2.   

     e.Cancel = true; 
      

  3.   

    直接设置窗体的MinimizeBox为False不就可以了?