Force Windows to show a system tray icon

房东的猫 提交于 2020-01-24 03:49:08

问题


This is a pretty stupid question, but here goes:

Is there a way (in .net) to force Windows to show your system tray icon instead of hiding it? I don't want to do this all the time, but at least for the first time my application is run I would like it to be visible in the system tray.


回答1:


Are you taking about Windows 7? If so, then no.




回答2:


As Raymond Chen would say, "Imagine if this were possible." Now tell me how many apps would choose not to force their tray icon to be always visible! Everybody thinks their tray icon is the most important. If there was a programmatic way to say "show my tray icon all the time", we'd be back to Windows 95.

Configuration of tray-icon hiding is left to the user, on purpose. If you want to always see your tray icon on your computer, there's nothing stopping you. Just right-click on the expander button, click "Customize Notification Icons" (that's what it's called in Vista, may vary in other OS versions), find your app's tray icon in the list, and select "Show".




回答3:


it does not show because, even if you uninstall your application, the display setting is saved under the PastIconsStream registry entry. Windows saves the settings for icon identifiers even if the app isn't already installed. For the first install, it will appear, then hide itself (which is what you want to achieve, I think). For subsequent installs, it won't appear anymore, because Windows remembers the setting. If you are still testing your application, try clearing the PastIconsStream registry entry. This will revert back to the "show at first, then hide" behavior.




回答4:


The first time your tray icon is shown, it will be made visible, at least for a short time. The rest is left up to the user - if they want to hide it then you should really respect that decision.




回答5:


There is no way to force it to be visible (as noted above, and rightly so), however if you show a balloon notification (like Windows Live Messenger does when you first try to close the window), your icon will appear while the balloon is visible. You could also use this to draw attention to your app to say "look at me, I'm down here!".

Please, for the sake of your users, make it only do this once, at most, though!



来源:https://stackoverflow.com/questions/958817/force-windows-to-show-a-system-tray-icon

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