将一个程序在启动时系统托盘 [英] Put a program in the system tray at startup
问题描述
我跟常用联尖减少应用程序到系统托盘:<一href="http://www.developer.com/net/csharp/article.php/3336751">http://www.developer.com/net/csharp/article.php/3336751现在,它的工作原理,但仍有一个问题:在启动时我的应用程序显示,我希望它直接在系统托盘启动。我试图尽量减少和隐藏在Load事件,但不起任何作用。
I followed the commonly-linked tip for reducing an application to the system tray : http://www.developer.com/net/csharp/article.php/3336751 Now it works, but there is still a problem : my application is shown when it starts ; I want it to start directly in the systray. I tried to minimize and hide it in the Load event, but it does nothing.
编辑:我可以作为一个海报建议,修改快捷方式的属性,但我宁愿用code:我没有完全控制软安装在每台计算机
Edit : I could, as a poster suggested, modify the shortcut properties, but I'd rather use code : I don't have complete control over every computer the soft is installed on.
我不希望来自世界各地的完全删除它除了系统托盘,我只是希望它开始最小化。
I don't want to remove it completely from everywhere except the systray, I just want it to start minimized.
任何想法?
感谢
推荐答案
在你的主程序你可能有一条线的形式是:
In your main program you probably have a line of the form:
Application.Run(new Form1());
这将强制形式来显示。您将需要创建形式,但是的不是的把它传递给 Application.Run
:
This will force the form to be shown. You will need to create the form but not pass it to Application.Run
:
Form1 form = new Form1();
Application.Run();
请注意,该方案现在将不会终止,直到您叫 Application.ExitThread()
。这是最好的从一个处理程序 FormClosed
事件做到这一点。
Note that the program will now not terminate until you call Application.ExitThread()
. It's best to do this from a handler for the FormClosed
event.
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
Application.ExitThread();
}
这篇关于将一个程序在启动时系统托盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!