[英]Minimize my winform application into system tray
我嘗試將winform應用程序最小化到系統托盤中,當最小化我的應用程序時,它仍然在任務欄中打開而不是在系統托盤中,並在幾秒鍾后關閉自動我添加了NotifyIcon
控件並注冊到Resize
事件:
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;
}
}
嘗試這個:
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;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.