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.
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 )
.
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.