Using Tooltip Controls
This section contains examples that demonstrate how to create different types of tooltips.
In this section
| Topic | Description |
|---|---|
|
The following example function creates a tooltip and associates it with the control whose resource ID is passed in. | |
|
The following example demonstrates how to create a standard tooltip control for a window's entire client area. | |
|
Tracking tooltips remain visible until they are explicitly closed by the application, and can change position on the screen dynamically. They are supported by version 4.70 and later of the common controls. | |
|
Multiline tooltips allow text to be displayed on more than one line. | |
|
Balloon tooltips are similar to standard tooltips, but are displayed in a cartoon-style "balloon" with a stem pointing to the tool. Balloon tooltips can be either single-line or multiline. They are created and handled in much the same way as standard tooltips. | |
|
A nonintrusive way to display an explanatory message for a status bar icon is to implement a tooltip. The tooltip disappears when clicked, but you can also specify a time-out value. | |
|
In-place tooltips are used to display text strings for objects that have been clipped. For an illustration, see About Tooltip Controls. |
Send comments about this topic to Microsoft
Build date: 3/6/2012
I did not find any reason to include the WS_EX_TRANSPARENT style when creating the tooltip window as shown in Raymond's example code.
<blogs.msdn.com/b/oldnewthing/archive/2006/06/26/647365.aspx>
We do have a Dialog Box containing simple button controls. This buttons controls should have tool tips with dynamically created text.
The WM_NOTIFY message with TTN_GETDISPINFO should be sent to the window of dialog box.
At this time we will not get any WM_NOTIFY message with TTN_GETDISPINFO for that control.
Is thre any sample code how this really works ?
------------------------------------------
I did not have any problems getting this to work using the CreateToolTip sample provided. I just called
CreateToolTip(IDOK, hwndDlg, LPSTR_TEXTCALLBACK);
in response to the WM_INITDIALOG message and added a handler for the WM_NOTIFY TTN_GETDISPINFO notification. (Of course, you wouldn't want to call CreateToolTip for every control since it creates a tooltip window - create one tooltip window and then add the controls as tools.)
Environment:
VC++ 2010 (express), no MFC
Subclassed owner drawn Tab Control with 4 rectangular regions in each tab for tooltips.
(three buttons and one label).
My solutions (2):
(1):
TOOLINFO ti;
It turns out that sizeof( ti ) = 48
I wasn't using the last two members, lParam and iReserved.
So I hard coded ti.cbsize to 40;
Then I stopped getting a return value of FALSE from SendMessage( hToolTip, TTM_ADDTOOL, 0, &ti );
(2):
Since I subclassed the tab control to intercept WM_MOUSEMOVE messages in order to
highlight the 4 rectangular regions, I was returning 0.
I changed this to: return ( lpfOriginalCallBack( hTabControl, msg, wParam, lParam )
and that did it :)
No need to use TTM_RELAYEVENT!
HTH
- 4/10/2011
- DjtS
#define WINVER 0x0400
#define _WIN32_WINDOWS 0x0400
#define _WIN32_WINNT 0x0400
#define _WIN32_IE 0x0500
Make sure to add this before any includes. I suspect that the same applies to VS2005 and VS2008 but I did not test that.
Alternatively, you can add the following line at the beginning of your stdafx.h:
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
Also:
1. the toolID parameter in the CreateTrackingToolTip function is not used. You can exclude it.
2. The following line can be commented:
//g_toolItem.uId = (UINT_PTR)hDlg;
3. The TTF_IDISHWND flag is also not required. Replace the following line:
g_toolItem.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE;
with
g_toolItem.uFlags = TTF_TRACK | TTF_ABSOLUTE;.