2014-02-18 97 views
0

我要儘量減少我的WinForm應用程序到系統托盤時,最小化我的應用程序在任務欄,而不是在系統托盤中仍然開放,幾秒鐘 收盤後自動我已經添加NotifyIcon控制寄存器到Resize事件:儘量減少我的WinForm應用程序到系統托盤

private void MainWin_Resize(object sender, EventArgs e) 
    { 
     if (FormWindowState.Minimized == this.WindowState) 
     { 
      notifyIcon1.Visible = true; 
      notifyIcon1.ShowBalloonTip(500); 
      this.Hide(); 
     } 
     else if (FormWindowState.Normal == this.WindowState) 
     { 
      notifyIcon1.Visible = false; 
     } 
    } 
+0

如何解決呢? (你讀過我寫的東西嗎?) – user3271698

+0

你可以看到http://stackoverflow.com/questions/1297028/having-the-application-minimize-to-the-system-tray-when-button-is-clicked – Akrem

+0

http://stackoverflow.com/questions/46918/whats-the-proper-way-to-minimize-to-tray-ac-sharp-winforms-app – Akrem

回答

2

試試這個:

private void MainForm_Resize(object sender, EventArgs e) 
    { 
     switch (this.WindowState) 
     { 
      case FormWindowState.Maximized: 
       this.ShowInTaskbar = true; 
       break; 
      case FormWindowState.Minimized: 
       this.ShowInTaskbar = false; 
       break; 
      case FormWindowState.Normal: 
       this.ShowInTaskbar = true; 
       break; 
      default: 
       break; 
     } 
    }