最小化时如何将.net应用程序放在系统托盘中? [英] how to put an .net application in system tray when minimized?
本文介绍了最小化时如何将.net应用程序放在系统托盘中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以建议一个vb.net/c#代码的良好代码示例,以便在最小化时将其放入系统托盘.
can anyone please suggest a good code example of vb.net/c# code to put the application in system tray when minized.
推荐答案
向您的表单添加一个NotifyIcon控件,然后使用以下代码:
Add a NotifyIcon control to your form, then use the following code:
private void frm_main_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.ShowInTaskbar = false;
this.Hide();
notifyIcon1.Visible = true;
}
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.ShowInTaskbar = true;
notifyIcon1.Visible = false;
}
您可能不需要设置ShowInTaskbar属性.
You may not need to set the ShowInTaskbar property.
这篇关于最小化时如何将.net应用程序放在系统托盘中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文