ToolTip Class for VB6 Forms
The attached file contains a replacement (or augment) to the ANSI-only, boxy, single-line tooltips provided by VB6. Features of the new class include:
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Usage
Include the class module clToolTips in your project. At the top of each form declare it such as this:
Then in your Form_Load procedure set the module and call the NewSetUp procedure:
At this point, the class module knows all about your form and its controls. It has set default values for each of the variables discussed below. You have several ways of setting tooltips now or at any point in the run. Many controls have a ToolTipText property which you can set at design-time or at run-time. The system used in this class module doesnt make use of any of those because VB6 uses a different method for showing tooltips. But you have the option of using those old ToolTipText values to set the new tooltips. You can do it for one control using the Sub UseToolTipText or use the sub DoAllToolTips to make new tooltips out of any controls that have a value set for ToolTipText.
The main procedure in the class module is SetToolTip and it allows you to specify the tooltip, whether you want an icon shown and optionally a title.
One of the nifty things about this tooltip system is that you can have multiline tooltips which can occur in two ways. You can specify a maximum width for one or all of the tooltips (discussed below) and if the tooltip text you supply is wider than the maximum tooltip width then Windows automatically looks for spaces to break the lines. Also, quite often you will want more control over where lines break so you can include vbCrLf (or vbNewLine) in your text wherever you want a line break. This gets to be a hassle so you may want to use a shortcut we provide (``) which gets converted into a vbCrLf for you. This character is the uppercase of the tilde character just to the left of the 1 key on Western keyboards. You can change this constant in the class module to be whatever you want. I suggest finding some key on the keyboard that you rarely use and put 2 of them in the constant ReplvbCrLf which is defined around line 166.
You can deactivate or reactivate any tooltip at any time with the ActivateOrNot procedure.
You can delete a tooltip by using DeleteToolTip.
Variables
There are some variables that are set to default values but you can change them at any time. Once changed, the variable holds that value until you change it again. For example, if you change the text color of the first tooltip you design you can leave the color value alone and all subsequent tooltips will use the same color.
Beware that some of the variables you can set are ignored if your program uses Visual Styles (themes) because Windows will choose for you. So far, I have found that text color, background color and the 4 internal margin settings are affected by this. BTW, if you are using a control that has the capability to use VisualStyles (like Krools VBCCRxx controls), it apparently doesnt matter if you have VisualStyles turned on or off for a given control because Windows takes over. I think this must be that the tooltip is actually a new window (complete with its own handle) and if VisualStyles are no for the program then the new windows have them turned on as well.
TTForeColor As Long Sets the text color (ignored if using VisualStyles). Default -1& which tells the system to let Windows choose the text color. You can use any RGB color or VB constants such as vbGreen.
TTBackColor As Long Background color for the tooltip. Default -1& which means let Windows decide. This value is ignored if using VisualStyles.
TTCentered As Boolean- True => center the text; False => left justify. Default is False.
TTBalloon As Boolean- True => use a balloon with a stem that points to your control. False => Use a rectangle for the tooltip. Default is True.
TTWrapTextLength As Long- This is another method of controlling the horizontal size of the tooltip but this one is based on a width in terms of characters in the tooltip rather than a maximum iwdth in pixels. For example, suppose you set a wide max tooltip of half of the screen width but you had a line of text that you wanted to limit to 40 characters. You could do that by setting this variable to 40. You would not have a wide tooltip; Windows will only make the tooltip wide enough to handle the 40-character width. I dont use this method much so I hae set the default at 0 which means it is not used. BTW, the code for this was modified from some code Elroy on vbForums gave me.
TTTipWidth As Single- This sets the maximum width of the tooltip expressed in terms of a fraction of the width of the screen with the form and controls. It does not set the width of the tooltip, oonly the maximum. For example, if you set this to 1 you are telling the system that your tooltip can be as wide as the screen but if you set a tooltip with the text Hello World the tooltip will be very small. ON the other hand, if you dont specify line breaks in your tooltip text and the length of the tooltip string is such that it is wider than the maximum toolptip size, Windows will do the line breaks for you and the width of the tooltip will be whatever you have set here as the maximum. If you set this to 0 then there is no text wrapping. The default is 0.3, 30% of your screens width.
TTDelayTime As Integer- Sets how long (milliseconds) a pointer must be stationary over the control for the tooltip to pop up. The default is -1 which will use Microsofts default time.
TTVisibleTime As Integer- Sets how long the tooltip will display if the pointer is stationary. The default is -1 which means Windows handles it (Windows sets this to be 10 times the delay time above).
TTReshowTime As Integer- Sets the amount of time for subsequent tooltips to appear as the pointer moves from one control to another. The default is -1 which lets Windows handle it (Windows sets it to 1/5th the delay time.
TTMarginsTop As Long- If nt using VisualStyles you can override the Windows defaults and set your own margins for top, left, bottom and right in pixels. If Top = -1 Windows defaults are used for all margins.
TTMarginsLeft As Long- See above discussion. The default is -1.
TTMarginsBottom As Long- See above discussion. The default is -1.
TTMarginsRight As Long- See above discussion. The default is -1.
Image may be NSFW.
Clik here to view.![Name: Hyperlink Tooltip.png
Views: 40
Size: 31.2 KB]()
The attached file contains a replacement (or augment) to the ANSI-only, boxy, single-line tooltips provided by VB6. Features of the new class include:
- Full Unicode support.
- RightToLeft support for tooltips on controls and the form itself.
- Multi-line tooltips.
- Tooltips can have titles.
- Tooltips can be rectangular or balloons with stems.
- Some instrinsic controls can have tooltips that cannot be set in traditional VB6 including the form itself, CheckBox, HScrollBar and VScrollBar.
- If you are not using VisualStyles, you can set tooltip text and background colors and the margins between the edge of the tooltip and the text.
- You can set the maximum width of the toolbar and if your line of text is wider than that, Windows will determine where to break lines.
- You can set how long to delay before pop-up, how long to display the tooltip and how long to re-display the tooltip when yo move away and come back.
- You can quickly update the text n a tooltip.
- You can deactivate/reactivate any tooltip at any time.
- You can put a hyperlink in a tooltip and it will show up as such. I havent yet figured out to be able to click on it because the tooltip either moves away or disappears when I go after it. Ill figure it out soon. I suspect I have to fix the tooltip position and keep it displayed a bit.
- This system is very simple to use. It requires no special files of any kind.
- No hooks, callbacks or sub-classing is used (Windows does some but we re protected from it) so using these tooltip functions within the IDE is perfectly safe.
- The module is very small, adding only 16k to your file.
Image may be NSFW.
Clik here to view.

Image may be NSFW.
Clik here to view.

Usage
Include the class module clToolTips in your project. At the top of each form declare it such as this:
Code:
Private myToolTips As clToolTips
Code:
Set myToolTips = New clToolTips
myToolTips.NewSetUp Me
The main procedure in the class module is SetToolTip and it allows you to specify the tooltip, whether you want an icon shown and optionally a title.
One of the nifty things about this tooltip system is that you can have multiline tooltips which can occur in two ways. You can specify a maximum width for one or all of the tooltips (discussed below) and if the tooltip text you supply is wider than the maximum tooltip width then Windows automatically looks for spaces to break the lines. Also, quite often you will want more control over where lines break so you can include vbCrLf (or vbNewLine) in your text wherever you want a line break. This gets to be a hassle so you may want to use a shortcut we provide (``) which gets converted into a vbCrLf for you. This character is the uppercase of the tilde character just to the left of the 1 key on Western keyboards. You can change this constant in the class module to be whatever you want. I suggest finding some key on the keyboard that you rarely use and put 2 of them in the constant ReplvbCrLf which is defined around line 166.
You can deactivate or reactivate any tooltip at any time with the ActivateOrNot procedure.
You can delete a tooltip by using DeleteToolTip.
Variables
There are some variables that are set to default values but you can change them at any time. Once changed, the variable holds that value until you change it again. For example, if you change the text color of the first tooltip you design you can leave the color value alone and all subsequent tooltips will use the same color.
Beware that some of the variables you can set are ignored if your program uses Visual Styles (themes) because Windows will choose for you. So far, I have found that text color, background color and the 4 internal margin settings are affected by this. BTW, if you are using a control that has the capability to use VisualStyles (like Krools VBCCRxx controls), it apparently doesnt matter if you have VisualStyles turned on or off for a given control because Windows takes over. I think this must be that the tooltip is actually a new window (complete with its own handle) and if VisualStyles are no for the program then the new windows have them turned on as well.
TTForeColor As Long Sets the text color (ignored if using VisualStyles). Default -1& which tells the system to let Windows choose the text color. You can use any RGB color or VB constants such as vbGreen.
TTBackColor As Long Background color for the tooltip. Default -1& which means let Windows decide. This value is ignored if using VisualStyles.
TTCentered As Boolean- True => center the text; False => left justify. Default is False.
TTBalloon As Boolean- True => use a balloon with a stem that points to your control. False => Use a rectangle for the tooltip. Default is True.
TTWrapTextLength As Long- This is another method of controlling the horizontal size of the tooltip but this one is based on a width in terms of characters in the tooltip rather than a maximum iwdth in pixels. For example, suppose you set a wide max tooltip of half of the screen width but you had a line of text that you wanted to limit to 40 characters. You could do that by setting this variable to 40. You would not have a wide tooltip; Windows will only make the tooltip wide enough to handle the 40-character width. I dont use this method much so I hae set the default at 0 which means it is not used. BTW, the code for this was modified from some code Elroy on vbForums gave me.
TTTipWidth As Single- This sets the maximum width of the tooltip expressed in terms of a fraction of the width of the screen with the form and controls. It does not set the width of the tooltip, oonly the maximum. For example, if you set this to 1 you are telling the system that your tooltip can be as wide as the screen but if you set a tooltip with the text Hello World the tooltip will be very small. ON the other hand, if you dont specify line breaks in your tooltip text and the length of the tooltip string is such that it is wider than the maximum toolptip size, Windows will do the line breaks for you and the width of the tooltip will be whatever you have set here as the maximum. If you set this to 0 then there is no text wrapping. The default is 0.3, 30% of your screens width.
TTDelayTime As Integer- Sets how long (milliseconds) a pointer must be stationary over the control for the tooltip to pop up. The default is -1 which will use Microsofts default time.
TTVisibleTime As Integer- Sets how long the tooltip will display if the pointer is stationary. The default is -1 which means Windows handles it (Windows sets this to be 10 times the delay time above).
TTReshowTime As Integer- Sets the amount of time for subsequent tooltips to appear as the pointer moves from one control to another. The default is -1 which lets Windows handle it (Windows sets it to 1/5th the delay time.
TTMarginsTop As Long- If nt using VisualStyles you can override the Windows defaults and set your own margins for top, left, bottom and right in pixels. If Top = -1 Windows defaults are used for all margins.
TTMarginsLeft As Long- See above discussion. The default is -1.
TTMarginsBottom As Long- See above discussion. The default is -1.
TTMarginsRight As Long- See above discussion. The default is -1.
Image may be NSFW.
Clik here to view.