How to hide a taskbar balloon at will?
Asked Answered
C

2

3

It's very easy to force a taskbar icon to display a balloon tooltip: all I need to do is set the NIF_INFO flag when calling Shell_NotifyIcon( NIM_MODIFY, ... ), and the balloon appears, no problem.

Now, I want to be able to hide the balloon when I no longer need it, as well, but I can't find a way to do that. I tried clearing the NIF_INFO flag and calling Shell_NotifyIcon( NIM_MODIFY, ... ), but the balloon remained. It does disappear by itself, a few seconds later, but that's not what I want: I want to hide it right away, when my program thinks it should be hidden.

The only way to make the balloon disappear seems to be to destroy the icon and then add it to the taskbar again, but it's ugly.

Is it possible to hide the balloon without recreating the taskbar icon? Thanks.

Charron answered 23/5, 2009 at 22:29 Comment(0)
C
4

To immediately hide a balloon, set the szInfo member of the NOTIFYICONDATA to an empty string, like nid.szInfo[0] = 0; and call Shell_NotifyIcon( NIM_MODIFY, &nid ).

Charron answered 24/5, 2009 at 0:53 Comment(0)
H
3

I would offer that its not really in the best interest of the user to forcibly remove a notification balloon. Sometimes a user doesn't look at a notification immediately, and that slow fade away that happens over a couple seconds gives them a chance to take a look before the balloon is gone. From a usability perspective, displaying the balloon should be the responsibility of the application, but removal of the balloon should really be the responsibility of the user. Otherwise, you could be hiding information they were actually interested in seeing, and by forcibly hiding it immediately, you completely remove that "last chance" the user has during the balloons fade away.

Hetero answered 23/5, 2009 at 23:12 Comment(3)
You are right that in some instances the balloon should stay in place to give the user time to review it, but there are plenty of cases in which the removal of the balloon should provide a better experience. For example, suppose I want to inform the user that my program is attempting to connect to a server. The connection may take just a second, after which point there is no point in keeping the "Connecting to the server..." balloon up. In fact, it may confuse the user: the connection has already been made, but the balloon says "connecting...", is there should something wrong with the program?Charron
So rather than hiding the balloon...change its text to say "Connected." and still allow the user to close it on their own. ;)Hetero
Balloons should be used only for notification about non-critical events. MS Outlook shows a balloon when connection to Exchange server is lost and is not restored for a specified period of time, then it shows a balloon when it restored the connection. Nothing bad happens if users miss it, doesn't it? Showing a balloon to notify your app is trying to connect could be very annoying if it takes several attempts. But you can change the icon so that users see your app is connecting to the server and update the status displayed when user hovers over your icon.Arbiter

© 2022 - 2024 — McMap. All rights reserved.