1、插入notifyIcon控件
2、在程序中加入代码
private bool windowCreate = true;
protected override void OnActivated(EventArgs e)
{
if (windowCreate)
{
base.Visible = false;
windowCreate = false;
}
base.OnActivated(e);
}
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
{
if (this.Visible == true)
{
this.Hide();
this.ShowInTaskbar = false;
}
else
{
this.Visible = true;
this.ShowInTaskbar = true;
this.WindowState = FormWindowState.Normal;
//this.Show();
this.BringToFront();
}
}