c#窗体点击关闭按钮怎么最小化到托盘中而不退出程序?
展开全部
#region 窗体最小化到状态栏
private void MainForm_FormClosing(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{ e.cancel= true; //取消关闭窗体事件
notifyIcon1.Visible = true;
this.Hide();
this.ShowInTaskbar = false;
}
} private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) //双击最小化图标显示窗体
{
if (this.ShowInTaskbar == false)
{
notifyIcon1.Visible = true;
this.ShowInTaskbar = false;
this.Show();
this.Activate();
this.WindowState = FormWindowState.Normal;
}
}
private void MainForm_FormClosing(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{ e.cancel= true; //取消关闭窗体事件
notifyIcon1.Visible = true;
this.Hide();
this.ShowInTaskbar = false;
}
} private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) //双击最小化图标显示窗体
{
if (this.ShowInTaskbar == false)
{
notifyIcon1.Visible = true;
this.ShowInTaskbar = false;
this.Show();
this.Activate();
this.WindowState = FormWindowState.Normal;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询