五、将 contextMenuStrip绑定到notifyIcon控件
设置notifyIcon样式
Icon图标以及text提示信息
//隐藏窗体
this.Visible = false;
//图标显示在托盘区
notifyIcon1.Visible = true;//弹出气泡提示
//notifyIcon1.ShowBalloonTip(2000, "提示", "双击图标恢复", ToolTipIcon.Info);
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
//显示窗体
this.Visible = true;
//激活窗体并给予它焦点
this.Activate();
//托盘区图标隐藏
notifyIcon1.Visible = false;
}
private void 还原ToolStripMenuItem_Click(object sender, EventArgs e)
{ //显示窗体
this.Visible = true;
//激活窗体并给予它焦点
this.Activate();
//托盘区图标隐藏
notifyIcon1.Visible = false;
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}