I have a Tray icon in my application. I am showing the balloon tip for 20 seconds, when I am loading something in the background. But, if the background load gets completed early, say in 10 seconds, I would like to hide the balloon tip. Currently the only way to hide the balloon tip is to click the close icon in the balloon tip.
Public Tray As NotifyIcon
Tray = New NotifyIcon
Tray.BalloonTipIcon = ToolTipIcon.Info
Tray.BalloonTipText = "Loading"
Tray.BalloonTipTitle = "Please Wait"
Tray.ShowBalloonTip(20 * 1000)
Is it possible to hide the balloon tip programmatically before the specified time is reached?
There are certainly better ways to do this. "Please wait" kind of feedback is best done with a progress bar or an hourglass mouse cursor. You can make it fancy on Win7+ with the Windows API Code Pack by displaying progress in the task bar button.
Anyhoo, you can pop a balloon by displaying another one with a short time-out or hiding the notification icon.
You can at any time hide the balloon tip (Visible property).
Note that tray icons and balloons are owned and controlled by explorer.exe ("start menu bar"), so if you don't clean it up properly it will stay there. You need to actively tell it to disappear. Setting a timer for the baloon simply tells explorer how long to show it. You need to actively send a counter-message to hide it before.
I'd personally think that it would be easier to just call
Tray.Show(0);
Which should force it to immediately hide the tray baloon without hiding the tray icon itself...
At least on current Windows 8.1 using .Net Framework 4 Client Profile,
popping BallonTip while keeping System.Windows.Forms.NotifyIcon notifyIcon1 visible
wanted back-to-back:
notifyIcon1.Visible = false;
notifyIcon1.Visible = true;