22 out of 30 rated this helpful - Rate this topic

Using Tooltip Controls

This section contains examples that demonstrate how to create different types of tooltips.

In this section

TopicDescription

How to Create a Tooltip for a Control

The following example function creates a tooltip and associates it with the control whose resource ID is passed in.

How to Create a Tooltip for a Rectangular Area

The following example demonstrates how to create a standard tooltip control for a window's entire client area.

How to Implement Tracking Tooltips

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.

How to Implement Multiline Tooltips

Multiline tooltips allow text to be displayed on more than one line.

How to Implement Balloon Tooltips

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.

How to Implement Tooltips for Status Bar Icons

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.

How to Implement In-Place Tooltips

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

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
In-place Tooltips
I found it necessary to include the TTF_TRANSPARENT flag when creating a tool that is to be used as an in-place tooltip as Raymond Chen demonstrates in his "Coding in-place tooltips" blog post. I think that this should be noted in the "Implementing In-Place Tooltips" section.

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>
Creating a Tooltip for a Control using LPSTR_TEXTCALLBACK ?
How to create a Tooltip for a Control using LPSTR_TEXTCALLBACK for dynamically created Tool Tip text?

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.)
Tooltips for Subclassed Tab Control
I had some difficulty getting this to work.
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
Getting the Tracking ToolTip example to work.
I could not get the tracking ToolTip example to work in my VS2010 Win32App (No MFC) project unles I added the following to my stdafx.h:

#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;.



i need Tooltip project
i need Tooltip  project