关闭窗体事件,加代码后,程序运行,电脑就注销不了,关机不了,哪位知道怎么解决呀?
  
      private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
            this.notifyIcon1.Visible = true; //显示为系统托盘图标
        }

解决方案 »

  1.   

    不会
    private void Form1_FormClosing(object sender, FormClosingEventArgs e) 
    {
      if( e.CloseReason == CloseReason.UserClosing )
      {
        e.Cancel = true;
        this.Visible = false;
      }

    拦截消息protected override void WndProc(ref Message m)
    {
    //获取系统消息:系统级别关闭为17 
    if ((m.Msg == 17)) { 
    ToClosed = true;
    Application.Exit();
    }
    base.WndProc(m);
    }