The sample demonstrates how to add multiline and text alignment support to your VB tooltips. It's done the hard way, by subclassing the tooltip window and handle all the drawing. But the code is encapsulated in a BAS module that can be included in any project, and used by simply adding two function calls. Users familiar with the Windows API can customize the drawing routine to add extra effects.
The code only works on the tooltips provided by VB's Extender object and that is added to all contorls. It will not affect tooltips created internally by controls, such as the ListItem tips in a ListView control.
For an alternative way to create multiline tooltips, based on the control in Comctl32.dll, see the links below.
Details
A VB program will only have one single tooltip window per process. The window has the classname "VBBubble" in the IDE, and "VBBubbleRT5" or "VBBubbleRT6" during runtime, depending on VB version. The window is created the first time the mouse cursor passes over the client area of a Form or UserControl (first WM_MOUSEMOVE message).
While working in the IDE, the tooltip window will not be destroyed as you start and stop the application. The same window will be used until you quit VB.
This sample first uses the EnumThreadWindows function to try to locate an existing tooltip window. If that fails, it sets up a thread CBT hook using SetWindowsHookEx so the application gets notified when a window is created. In any case, when a tooltip window is found, it's subclassed. The module will then handle the WM_WINDOWPOSCHANGING and WM_PAINT messages so that the window is sized and drawn like we want it.
To enable this, call the HookToolTips function in the module. This is normally done sometime during application startup, in Form_Load or Sub Main. You also have to call the UnhookToolTips function before the application ends to remove the subclass. Not doing that might cause the application to crash when closed.