我试图在表单关闭时显示 NotifyIcon 。它关闭了,但是当我单击最小化按钮时它也关闭了。这是我的代码。
private void Home_Resize(object sender, EventArgs e)
{
if (FormWindowState.Minimized == this.WindowState)
{
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(500);
this.Hide();
}
else if (FormWindowState.Normal == this.WindowState)
{
notifyIcon1.Visible = true;
}
}
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Show();
this.Activate();
this.WindowState = FormWindowState.Normal;
}
}
private void Home_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.WindowState = FormWindowState.Minimized;
}
private void toolStripMenuItem1_Click_1(object sender, EventArgs e)
{
//Exit App
notifyIcon1.Visible = false;
Environment.Exit(0);
}