Tooltips in a Window Region



A reader of these pages asked if it was possible to have API tooltips work in an arbitrary region of a window rather than for defined controls. This is possible and only requires a slight modification to the procedure for controls.

In the TBarExmp.f code, there is a TOOLINFO structure named lpToolInfo. To use this to add a control tool you put the control handle in lpToolInfo.uId and set the TTF_IDISWHND flag. If you want to specify an arbitrary region in a client window, you use the lpToolInfo.rect parameter to specify a rectangle and don't set the TTF_IDISWHND flag. If the cursor is inside this rectangle, the tooltip will be displayed.

A modification of the Toolbar Example is included showing how this is done. This is also covered in the Win32 Programmer's Reference in the section Creating a Tooltip Control. The picture below shows the tooltip for a region shown by the lines (the lines aren't necessary, they just make it easier to see where the cursor should be).





Keep those cards and letters coming ;-)



Author: Jeff Kelm, (how to contact me)
URL: http://www.concentric.net/~jkelm/win32for/classlib/tooltips.htm
(Modified: 2005-01-07)