How to always show program tray icons in Windows by *default*?
Asked Answered
N

3

10

If a program is executed for the first time in Windows 7, it automatically hides the icon. Is there any manifest setting or option to force Windows 7 to always show the icon by default?

Nevarez answered 24/5, 2009 at 22:22 Comment(0)
Z
14

In .NET Rocks podcast, not long time ago, Kate Gregory from Microsoft was saying that it is impossible.

She said something like: "If user wants it (tray icon) he/she will put it there". Reason for this is to prevent mess in the tray area.

Zootechnics answered 24/5, 2009 at 22:29 Comment(6)
In my opinion this is a fantastic thing. The system tray has been abused, and I've always tried to set everything to "always hide" to try reclaim screen real estateCloddish
Jamie, I would agree but keep in mind that there are types of apps where a tray icon is essentially required as the only access to the main program. And I know for sure that the Win7 will create MASSIVE support load "Where is the icon?".Nevarez
Well, actually it's probably possible... if the user can configure which tray icons he wants to display, it must be possible to configure it by code (probably by changing some registry value)Jacie
Mark: I think you should reconsider your program's design, in that case. The tray is not meant to be used like that. End of story.Disaffection
@Mark: That's the user's call, in the end. You can always show a popup balloon pointing out where did the icon go. Moreover, you can move the tray icon to autoshow by simple click-dragging, so the effort's minimal.Percyperdido
One issue with the "it's up to the user" approach is that sometimes in enterprise environments, it's the organization that should be allowed to determine this stuff. Futhermore, in the case of a published Citrix application, there appears to be NO WAY to configure the icon to always show as the icon actually exists on a desktop which is inaccessible to the end user. In the end, for indivudal environments, up to the user usually works - but not always for the enterprise.Alderson
C
4

If you really want to show your tray-icon, you can popup a balloon with minimal text and just afterwards hide the balloon and it's shadow again by following code-example:

trayIcon.ShowBalloonTip(30000, "", ".", ToolTipIcon.None)

Dim balloonHandle As IntPtr = GetBalloonHwnd(balloonText) ' mainly: FindWindow("tooltips_class32", Nothing)

If (balloonHandle <> IntPtr.Zero) Then
  Dim sysShadowClassHwnd As IntPtr = FindWindow("SysShadow", Nothing)

  ' will hide balloon and leaving a small shadow artifact - just for this balloon
  PostMessage(balloonHandle, WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero)
  SetWindowPos(balloonHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_HIDEWINDOW)

  If (sysShadowClassHwnd <> IntPtr.Zero) Then
    ' this will remove the small shadow artifact
    PostMessage(sysShadowClassHwnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero)
  End If
End If

if you repeat this (e.g. every 30 seconds), your trayicon will stay there because Explorer.exe thinks, there is a balloon open to display to the user. A few minor issues - such as no right-click directly on icon - are still there.

I really used to show the tray icon for our company-software where the user are not intended to do this manually and for each update. So maybe this will help someone... :)

Otherwise, I totally agree: This should be only in hands of the user, not controlled by the application.

Charles answered 23/2, 2012 at 15:38 Comment(0)
T
3

It's certainly not "impossible". There is an undocumented COM interface ITrayNotify for retrieving tray icons and changing their visibility, used by Explorer itself. Full C++ source here: http://thread0.me/tag/windows/

Of course, using an unofficial API is risky and Windows 8 has intoduced breaking changes to this API, which means you have to use 2 different definitions for XP - Win7 and Win8 - Win10. But hey, even Chrome uses this trick. Just be sure to handle failures properly.

Tapdance answered 18/8, 2015 at 10:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.