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:
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:
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.
// 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.
Comments
Any ideas?
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]";
notifyIconMain.ShowBalloonTip(1000);
}
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);
}
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.... :-)
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.
It allows <128 characters, so double as much. If you need more than 128 than the BalloonTip is the correct solution.