C# 窗體最小化到狀態欄 雙擊正常顯示窗體 (contextMenustrip 設置右鍵菜單)
首先在窗體中添加一個 notifyIcon1控件
[csharp]
//最小化時
private void Form1_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.notifyIcon1.Visible = true;
this.Visible = false;
}
}
[csharp]
//鼠標雙擊任務欄圖標顯示程序界面:
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (this.Visible == false)
this.Visible = true;
}
摘自 歐陽小燕