Add Multiline Balloon Tooltips to ListView column Headers

Category:
Forms and Controls
Type:
Classes
Difficulty:
Advanced
Author:
10Tec Company

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
The attached code demonstrates a technique you can use to create multiline balloon tooltips for ListView column headers. The code uses subclassing technique to trap the WM_MOUSEMOVE event of the Header control which is a constituent part of the ListView control. The handler for this event determines the index of the column header under the mouse pointer and changes the tooltip text respectively; it uses the HDM_HITTEST message for this purpose.

To find the handle of the Header control inside ListView from MSCOMCTL.OCX, the code uses the FindWindowEx function which searches for the child window with the "msvb_lib_header" class inside the ListView control. The code also can be used to subclass the "pure" ListView control (its class name is "SysListView32"); to do it, you must replace the "msvb_lib_header" string on "SysHeader32".

The sample creates MS Windows tooltips with the CreateWindowEx function passing to this function the "tooltips_class32" class name. Balloon tooltips work only in Windows 2000/XP; in the previous versions of Windows you'll see old-style rectangular tooltips.

You can use this technique to create multiline balloon tooltips for any control that contains Windows Header control. For instance, we use this technique to create such tooltips for the grid control we produce (10Tec iGrid ActiveX control - visit www.10Tec.com for more info).


Instructions: Click the link below to download the code. Select 'Save' from the IE popup dialog. Once downloaded, open the .zip file from your local drive using WinZip or a comparable program to view the contents.

Download mbtlvchsample.zip