RT

解决方案 »

  1.   

    Form_Closing事件中写e.Cancel = true;
    this.Hide();
      

  2.   

    加一个NotifyIcon
    默认设置NotifyIcon.Visible=false;
    设置一个NotifyIcon的图案在FormClosing事件里
    e.Cancel = true;
    Hide();
    NotifyIcon.Visible = true;如果需要再让Form再显示,比如双击NotifyIcon显示,那就处理一下NotifyIcon的DoubleClick事件
    NotifyIcon.Visible = false;
    Show();
      

  3.   

    private void Form1_SizeChanged(object sender, EventArgs e)  
     {  
      if(this.WindowState==FormWindowState.Minimized)  
      {  
      this.Hide();  
      this.notifyIcon1.Visible=true;  
      }  
     }   private void notifyIcon1_Click(object sender, EventArgs e)  
     {  
      this.Visible = true;  
      this.WindowState = FormWindowState.Normal;  
      this.notifyIcon1.Visible = false;  
     }  
      

  4.   

    拦截WINDOW消息
      protected override void WndProc(ref Message m)
            {   
                switch( m.Msg ) 
                { 
                 case  0x0010:
                 {  WZorder.dal dal = new WZorder.dal();
                    if (ni.Visible != true)//NOTIFYICON
                    {   st st = new st();
                        st.ShowDialog();
                        st.StartPosition = FormStartPosition.CenterScreen; 
                       
                    else 
                    {    
                        this.WindowState = FormWindowState.Minimized;
                        this.ShowInTaskbar = false;
                    } 
                    break;
                   }
                  default:
                  base.WndProc(ref m);
                  break;            }        }