开发者

How to add ONLY system tray icon to application?

I am developing an application that will be running behind the scenes in Windows and would like to put an icon in the system tray for troubleshooting purposes (simple way for users to tell if the app is running). There is no other UI for the application, and the icon does not need to have any functionality as of right now.

All of the solutions I have found as of yet involve creating a form. I am wondering if there is a way to simply add a class to my current C# code that a开发者_StackOverflow社区llows me to control the icon, rather than doing the whole 'make a form, set it to be invisible....' nonsense that seems to be the popular suggestion on the forums. Something along the lines of the way that UI control is done in say, Swing for Java. I would really appreciate any ideas!


You can do it with a custom ApplicationContext. Google reveals first this tutorial on how to achieve it. Or you can alter your main Program file not to show any form at all:

Application.Run(); //remove the Form oject from this call


From whatever project you use, why not just create an instance of the NotifyIcon class and use it to display the icon in the system tray?


For Windows Forms:

Form.ShowInTaskbar to show/hide in the taskbar

and use a NotifyIcon to show in the tray

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜