1

HI,

I create balloon tips all over our application. My problem is that all of the balloon tips stay on the task-bar and needs to be hovered over for them to disappear.

        public static bool SetBalloonTip(string balloonTipTitle, string balloonTipText, ToolTipIcon balloonTipIcon)
    {
        bool result = false;
        NotifyIcon notifyIcon;

        try
        {
            notifyIcon = new NotifyIcon();

            notifyIcon.Icon = SystemIcons.Information;
            notifyIcon.BalloonTipTitle = balloonTipTitle;
            notifyIcon.BalloonTipText = balloonTipText;
            notifyIcon.BalloonTipIcon = balloonTipIcon;

            notifyIcon.Visible = true;
            notifyIcon.ShowBalloonTip(30000);

            result = true;
        }
        catch (Exception)
        {

            throw;
        }

        return result;
    }

My question is, how do i make the notify icon disappear after it has been shown?

Willem
  • 9,166
  • 17
  • 68
  • 92

3 Answers3

2

Are you displying more than one balloon at a time?

From MSDN:

Only one balloon tip can display on the taskbar at a time. Attempting to display a balloon tip when one is currently displayed on the taskbar causes the timeout value to be ignored.

http://msdn.microsoft.com/en-us/library/ms160064.aspx

raymelfrancisco
  • 828
  • 2
  • 11
  • 21
Ryan Bennett
  • 3,404
  • 19
  • 32
2

Found a solution:

first:

private static System.ComponentModel.IContainer components;

Second:

public static bool SetBalloonTip(string balloonTipTitle, string balloonTipText, ToolTipIcon balloonTipIcon)
    {
        bool result = false;
        NotifyIcon notifyIcon;

        try
        {
            if (components == null)
            {
                components = new System.ComponentModel.Container();
            }

            notifyIcon = new NotifyIcon(components);

            notifyIcon.Icon = SystemIcons.Information;
            notifyIcon.BalloonTipTitle = balloonTipTitle;
            notifyIcon.BalloonTipText = balloonTipText;
            notifyIcon.BalloonTipIcon = balloonTipIcon;

            notifyIcon.Visible = true;
            notifyIcon.ShowBalloonTip(30000);

            result = true;
        }
        catch (Exception)
        {

            throw;
        }

        return result;
    }

Third:

        public static void DisposeOfBallonTips(bool disposing)
    {
        try
        {
            // Clean up any components being used.
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
        }
        catch (Exception)
        {

            throw;
        }
    }

Calling DisposeOfBallonTips when i want to clean up all NotifyIcons.

Willem
  • 9,166
  • 17
  • 68
  • 92
0

I'm mostly guessing but try this

add an event handler like this and see if it helps.

     ...
     ... 
     notifyIcon.BalloonTipClosed += new EventHandler(notifyIcon_BalloonTipClosed);
     notifyIcon.ShowBalloonTip(30000);
     ...
}



static void notifyIcon_BalloonTipClosed(object sender, EventArgs e)
{
    ((NotifyIcon) sender).Visible = false;
}
Bala R
  • 107,317
  • 23
  • 199
  • 210