//**************************最小化系统托盘*********/
#region
private void ExitMainForm()
{
if (MessageBox.Show("您确定要退出程序吗?", "确定", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
{
this.notifyIcon1.Visible = false;
this.Close();
this.Dispose();
Application.Exit();
}
}
private void HideMainForm()
{
this.Hide();
}
private void ShowMainForm()
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.Activate();
}
#endregion
#region 右键菜单处理,显示 隐藏 退出
private void 显示ToolStripMenuItem_Click(object sender, EventArgs e)
{
ShowMainForm();
}
private void 隐藏ToolStripMenuItem_Click(object sender, EventArgs e)
{
HideMainForm();
}
private void 退出ToolStripMenuItem1_Click(object sender, EventArgs e)
{
ExitMainForm();
}
#endregion
#region 双击托盘上图标时,显示窗体
private void notifyIcon1_DoubleClick_1(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
{
this.WindowState = FormWindowState.Minimized;
HideMainForm();//我觉得这个可以不要了的
}
else
if (this.WindowState == FormWindowState.Minimized)
{
ShowMainForm();
}
}
#endregion
#region
private void ExitMainForm()
{
if (MessageBox.Show("您确定要退出程序吗?", "确定", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
{
this.notifyIcon1.Visible = false;
this.Close();
this.Dispose();
Application.Exit();
}
}
private void HideMainForm()
{
this.Hide();
}
private void ShowMainForm()
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.Activate();
}
#endregion
#region 右键菜单处理,显示 隐藏 退出
private void 显示ToolStripMenuItem_Click(object sender, EventArgs e)
{
ShowMainForm();
}
private void 隐藏ToolStripMenuItem_Click(object sender, EventArgs e)
{
HideMainForm();
}
private void 退出ToolStripMenuItem1_Click(object sender, EventArgs e)
{
ExitMainForm();
}
#endregion
#region 双击托盘上图标时,显示窗体
private void notifyIcon1_DoubleClick_1(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
{
this.WindowState = FormWindowState.Minimized;
HideMainForm();//我觉得这个可以不要了的
}
else
if (this.WindowState == FormWindowState.Minimized)
{
ShowMainForm();
}
}
#endregion