How-To... - Using ToolTips in your Program

In most Windows programs, you often find ToolTips. ToolTips are small tips, or labels, that popup when you put your mouse pointer over a certain button, image, label, etc. The tip usually displays what the control is and/or does i.e The Save Icon in VB - the tooltip says "Save Project" which lets you save your project. Using ToolTips help make the user of your program understand what a certain control does, and also makes your program more user-friendly.

To illustrate ToolTips, I will show you how to add them to a program.

You can use ToolTips with most controls, but for this tip I will use Image Controls. Set your form like the opposite picture.

The four labels should be called :- lblWalk, lblRed, lblAmber and lblGreen respectively. The images can be called anything you wish.

The tooltips are positioned below the images so that they popup properly when the mouse moves into the image. Make sure the Visible property of the labels is False. You don't want to see the ToolTip until the mouse pointer is moved into, or on top of, the image. Now time for some code.

Double click the first image, change to the MouseMove procedure and add the following code:-

lblWalk.visible=True

Do the same for the other images, changing lblWalk for the name of the label positioned below.

The above code is making the labels visible when they move into the corresponding image.

Now, if you run your program, and when you move the mouse into the image, the ToolTip will appear. But, when the mouse is moved back into the form, or away from the image, the ToolTip stays. Add the following code to the MouseMove section of the Form to fix this problem :-

lblWalk.Visible=False
lblRed.Visible=False
lblAmber.Visible=False
lblGreen.Visible=False


All this means is that when the mouse moves back into the form, the labels become invisible. If another object is also causing the ToolTips to stay visible when moved off the image, add the code to the MouseMove procedure of the object.

ToolTips are an easy, effective way to make your program more User-friendly.

If anything didn't make sense, you can download the Project File for this tip by clicking here

-----------

Tip supplied by David Cowan(dodgesoft@hotmail.com)


This site is Copyright © 1999 of David Cowan. VB How-To, Dodgesoft and DodgeSoft Productions is Copyright © 1999 of David Cowan. Source-code and programs are copyright of their respective owners. For a messageboard, click here