How to run an “empty” Windows Application that only has a NotifyIcon?

不羁岁月 提交于 2019-12-18 08:47:26

问题


I want to make an Application that only has a NotifyIcon. It doesn't need to have at all a "Main" Form. When I want to achieve something like this, I just create an invisible form and run it, but would there be a more "elegant" way of doing this, I'd like to know it.

How do you generally do this? This application can't be a Windows Service, as having the NotifyIcon and its Context Menus is important (each one of them will run a different command).

Thanks


回答1:


Check out this blog post:

As it turned out it was so easy it was ridiculous. All you have to do create a class that is inherits the iContainer interface. When you create the instance of the notify icon, pass a container object.

It gives you the notify icon, but not a context menu.




回答2:


Another approach is to use special ApplicationContext which will have only the controls you need: Creating a Tasktray Application.



来源:https://stackoverflow.com/questions/2788611/how-to-run-an-empty-windows-application-that-only-has-a-notifyicon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!