Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close BalloonTip programmatically?

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?

like image 534
Lenin Raj Rajasekaran Avatar asked Mar 15 '11 16:03

Lenin Raj Rajasekaran


4 Answers

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;
like image 144
blekenbleu Avatar answered Oct 07 '22 20:10

blekenbleu


Try this:

Tray.Visible = true;

More info here.

Hope helps!

like image 37
Morvader Avatar answered Nov 01 '22 04:11

Morvader


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.

like image 4
Hans Passant Avatar answered Nov 01 '22 05:11

Hans Passant


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.

like image 1
Tedd Hansen Avatar answered Nov 01 '22 04:11

Tedd Hansen