请把notifyIcon与button拖至窗口里后,在使用下面的代码
private bool windowsCreate = true;
private void button3_Click(object sender, EventArgs e) //点击时会隐藏窗口
{
if (windowsCreate) {
base.Visible = false;
windowsCreate = false;
}
this.Hide();
base.OnActivated(e);
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs 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();
windowsCreate = true;
}
}