C#关闭以后窗体最小化,双击以后窗体正常显示

 

此时需要增加C#控件(notifyIcon),为notifyIcon1增加图标

 

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;//取消窗体的关闭事件
this.WindowState = FormWindowState.Minimized;//使当前窗体最小化
notifyIcon1.Visible = true;//使最下滑的图标可见
}

 

//增加notifyIcon的双击事件

private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (this.WindowState == FormWindowState.Minimized) //判断当前窗体的状态是否为最小化
{
this.WindowState = FormWindowState.Normal;//将当前窗体状态恢复为正常
notifyIcon1.Visible = false;//将notifyIcon图标隐藏
}
}

posted @ 2015-05-13 11:46  shuke2016  阅读(3560)  评论(0编辑  收藏  举报