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?
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;
//...
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With