您的位置:首页 > 编程语言 > C#

c# 程序后台运行

2015-10-11 23:50 302 查看
请把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;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  对象 c# 窗口隐藏