Notify Icon Text vs BalloonTipText

Ok so I have a small application that shows a users ip address via a tool tip when it sits in their system tray. Everything is going fine until someone sends me a bug that there was a problem. Investigating this I find that the method I was using to display tool tips in the system menu is somewhat flawed. I was using a notify icon control to show the tool tips while in the system tray. This works but I was setting the Text property of the control like this:

// old way of setting text, with 64 character limit
this.notifyIcon1.Text = "Show me in the toolbar";

This works but only for up to 64 characters. When I was designing the application I was thinking about ip addresses using the v4 format not the v6 format. Sure enough v6 ip addresses kick out more then 64 characters a lot of the time. So the search was on and I found using the balloon text can show more data but is a wee bit harder to use. Balloon tool tips don't show automatically like the text does. You have to use the notify icons MouseMove event and call the ShowBalloonTip method of the notify icon. So the code below solved my issue:

// set the balloon tip text
this.notifyIcon1.BalloonTipText = "Some realy really really really really ................................ text";

// using the MouseMove event to show the balloon tool tip</span>
private void notifyIcon1_MouseMove( object sender, MouseEventArgs e )
   this.notifyIcon1.ShowBalloonTip( 10 )

So now when the user mouses over the icon while in the tray they get a very nice looking tool tip. The only issue is the balloon tool tip IS NOT supported on windows 95. An old OS to be sure but some folks are still running it.


Amjad Raja said…
MouseMove has a problem, when I pause mouse over the icon in sysTray, the method is called over and over again and the tooltip never goes away and instead blinks too much.

Any ideas?
Santosh G said…
U R rite buddy, even i was also having the same.
Finally i resolved it...

notifyIconMain.MouseMove += new MouseEventHandler(notifyIconMain_MouseMove);
notifyIconMain.BalloonTipShown += new EventHandler(notifyIconMain_BalloonTipShown);
notifyIconMain.BalloonTipClosed += new EventHandler(notifyIconMain_BalloonTipClosed);
notifyIconMain.BalloonTipClicked += new EventHandler(notifyIconMain_BalloonTipClicked);

void notifyIconMain_MouseMove(object sender, MouseEventArgs e)
notifyIconMain.BalloonTipTitle = "My Ballon Tip Title";
notifyIconMain.BalloonTipText = " - By Santosh.G [EGB]";

void notifyIconMain_BalloonTipShown(object sender, EventArgs e)
notifyIconMain.MouseMove -= new MouseEventHandler(notifyIconMain_MouseMove);

void notifyIconMain_BalloonTipClosed(object sender, EventArgs e)
notifyIconMain.MouseMove += new MouseEventHandler(notifyIconMain_MouseMove);

void notifyIconMain_BalloonTipClicked(object sender, EventArgs e)
notifyIconMain.MouseMove += new MouseEventHandler(notifyIconMain_MouseMove);
Santosh G said…
CPU usage will become very high when you keep the mouse pointer @the icon and it may even hang that program.
Coz the notifyIconMain_MouseMove method is called over and again (Untill the Mouse is over that program's icon) and the tooltip never goes away and also it blinks too much.
I hav resolved it - @Above Solution..

Enjoy.... :-)
jlechem said…
Excellent work!

Sorry I haven't been able to post before blogspot seemed to be broken and I couldn't post. This was a very stopgap solution and I was aware of issues with the tool tip solution but never found a good way to solve it gracefully. I will give that solution a try as I have a program that could use it.
jlechem said…
After testing out the code it works quite well. My only problem with the balloon is that it doesn't go away after you move the mouse. The user has to close the balloon tip. There is a strategic difference between a tool tip and the balloon tip. Balloon tips are meant to convey information the user should see and has to close the tip. Tool tips are just meant to show and close. So it's something to consider when choosing what to use.
Mike said…
Here's the real solution to the problem:

It allows <128 characters, so double as much. If you need more than 128 than the BalloonTip is the correct solution.

Popular posts from this blog

C# Form Application in Kiosk Mode/Fullscreen

C# using a transaction with ODBC