</pre><pre class="plain" name="code" code_snippet_id="108369" snippet_file_name="blog_20131211_1_6723383">
拖入notifyIcon控件,然后再写双击事件,再写项目主窗体的Resize,代码如下
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)//notifyIcon控件双击事件
{
this.Show();//显示当前窗口
this.ShowInTaskbar = true;//在任务栏中显示该窗口
WindowState = FormWindowState.Normal;//窗口状态
this.Focus();
this.BringToFront();
}
#endregion
private void TestSend12_9_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized) //隐藏到托盘与QQ相似
{
this.ShowInTaskbar = false;//不在任务栏中显示该窗口
this.Visible = true; //显示程序图标
this.Hide(); //隐藏窗口
}
}