views:

711

answers:

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.

+3  A: 

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.

jrista
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?
Andrei Belogortseff
So rather than hiding the balloon...change its text to say "Connected." and still allow the user to close it on their own. ;)
jrista
That's a good idea, thanks!
Andrei Belogortseff
+2  A: 

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

Andrei Belogortseff
A: 

Just FYI - I HATE ALL of the balloons. There is already an icon in the taskbar that tells me the same thing as the balloon words. The desktop is my workspace, and the balloons don't have any business intruding where they don't belong. They're like someone barging in and dropping a bunch of papers all over the worksheet or document I'm in the middle of working on. I have to lift them out of my way to see that corner of the monitor.

Yeah, sure, I can interrupt what I am doing, and move my focus and mouse to the ballooon to pop it and get it out of my way, but that spoils my concentration, and it's always for something that can wait until I get to it. Or worse, the software is interrupting me to say it's doing what it's SUPPOSED to be doing. Just shut up and get on with it.

The better alternative is simply to not intrude where you don't belong. If your software really wants to be sure I see something (otherwise known as nagging), make the icon blink or shift through 4 or 5 colors, but keep it where it belongs, in the taskbar, not in my workspace.

Loretta Yeo