需要Form的两个事件SizeChanged和notifyIcon对象的打击或双击对象
if (this.WindowState == FormWindowState.Minimized)
//判断是否最小化
{
this.ShowInTaskbar = false;
//不显示在系统任务栏
this.notifyIcon1.Visible = true;
//托盘图标可见
}
if (this.WindowState == FormWindowState.Minimized)
{
this.ShowInTaskbar = true; //显示在系统任务栏
this.WindowState = FormWindowState.Normal; //还原窗体
this.notifyIcon1.Visible = false; //托盘图标隐藏
}