我在写一个winform程序,希望按下关闭按钮只是将窗口最小化,或者将窗口隐藏了,并不是真的执行关闭。

解决方案 »

  1.   

    C#下没用过.在C++下可以拦截这个关系的Message来执行其他的代码的.我想C#下也应该可以这样来做的吧??
      

  2.   

    参看
    http://www.syncfusion.com/faq/windowsforms/Search/862.aspx
      

  3.   

    在onclosing里,
    先让e.cancel = true;
    然后再发送最小化命令
      

  4.   

    public const int SC_CLOSE = 0xF060; 
     
    public const int WM_SYSCOMMAND = 0x0112; 
      
    //_closeClick is a bool member of the form initially set false... 
     
    // It can be tested in the Closing event to see how the closing came about. 
      
    protected override void WndProc(ref System.Windows.Forms.Message m) 
     

     
         if(m.Msg == WM_SYSCOMMAND && (int)m.WParam == SC_CLOSE) 
     
              this._closeClick = true; 
      
         base.WndProc(ref m);