Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BalloonTipClicked (Closed/Shown) Sender/EventArgs

Tags:

c#

balloon-tip

I am trying to identify which BalloonTip (NotifyIcon) sent the BalloonTipClicked (and Closed, and Shown) events as I have a few different scenarios where balloons may be shown and they aren't all the same nor will have the same expected actions.

Does anyone know if you can identify anything about the BalloonTip that send the Clicked/Closed/Shown events?

like image 792
SmithPlatts Avatar asked Feb 19 '26 16:02

SmithPlatts


1 Answers

It's a bit of a workaround but you could create a method (or an extension method)

public static void ShowBalloonAndUpdate(this NotifyIcon ni, int timeout, string title, string text, ToolTipIcon icon )
{
    ni.BalloonTipTitle = title;
    ni.BalloonTipText = text;
    ni.BalloonTipIcon = icon;
    ni.ShowBalloonTip(timeout);
}

When you call the BalloonTip with that method, it will update the properties of the NotifyIcon.

myNotifyIcon.ShowBalloonAndUpdate(1000, "Hello" "My Message", ToolTipIcon.Info);

These properties can then be read in any of the BalloonTip events. You can decide what to do based on one of the properties (e.g. BalloonTitle)

private void myNotifyIcon_BalloonTipShown(Object sender, EventArgs e) 
{
    NotifyIcon ni = sender as NotifyIcon;
    if(ni != null)   
    {
        switch(ni.BalloonTitle)
        {
            case "Hello":
                  //Hello tooltip was shown
                  break;
            //...
        }
    }
}
like image 130
keyboardP Avatar answered Feb 22 '26 05:02

keyboardP