TTM_SETTITLE Message

Adds a standard icon and title string to a tooltip.

Syntax

To send this message, call the SendMessage function as follows.
lResult = SendMessage(    // returns LRESULT in lResult
   hWndControl,           // (HWND) handle to destination control
   TTM_SETTITLE,          // (UINT) message ID
   wParam,                // = (WPARAM)(int) icon; 
   lParam                 // = (LPARAM)(LPCTSTR) pszTitle;
);

Parameters

icon
Set wParam to one of the following values to specify the icon to be displayed. As of Windows XP Service Pack 2 (SP2) and later, this parameter can also contain an HICON value. Any value greater than TTI_ERROR is assumed to be an HICON.
TTI_NONE
No icon.
TTI_INFO
Info icon.
TTI_WARNING
Warning icon
TTI_ERROR
Error Icon
TTI_INFO_LARGE
Large error Icon
TTI_WARNING_LARGE
Large error Icon
TTI_ERROR_LARGE
Large error Icon
pszTitle
Pointer to the title string. You must assign a value to pszTitle.

Return Value

Returns TRUE if successful, FALSE if not.

Remarks

The title of a tooltip appears above the text, in a different font. It is not sufficient to have a title; the tooltip must have text as well, or it is not displayed.

When icon contains an HICON, a copy of the icon is created by the tooltip window.

When calling TTM_SETTITLE, the string pointed to by pszTitle must not exceed 100 TCHARs in length, including the terminating NULL.

Example

The following example shows how to add a title and a system icon to a tooltip.

// hwndTip is the handle of the tooltip window.
HICON hIcon = LoadIcon(NULL, IDI_INFORMATION);
SendMessage(hwndTip, TTM_SETTITLE, (WPARAM)hIcon, L"Title text");
DestroyIcon(hIcon);

Message Information

Minimum DLL Versioncomctl32.dll version 5.80 or later
Headercomctl32.h
Minimum operating systems Windows 2000, Windows NT 4.0 with Internet Explorer 5, Windows 98, Windows 95 with Internet Explorer 5

See Also

About Tooltip Controls
Tags :


Community Content

XenonOfArcticus
Caller responsible for freeing a hidden icon copy?
>When icon contains an HICON, a copy of the icon is created by the ToolTip window. The caller is responsible for freeing that copied icon.

This doesn't make any sense at all. How can the caller free a resource it has never seen? The handle of the copy is not returned to the caller as far as I can tell. And how would the caller know when the ToolTip window was done with the copy anyway? I suspect this is a documentation bug. I imagine the caller is responsible for freeing the original icon, but the ToolTip window frees the copied icon. -xenon (a in a circle) arcticus.kom

XenonOfArcticus
Tooltips with no text will not be displayed, even if they have a title and/or icon.
A tooltip must have text (possibly obtained viaTTN_NEEDTEXT in order to display at all. Setting a Title through TTM_SETTITLE is not sufficient.
Additionally, a Tooltip with an Icon but a blank title will not display the Icon.
Tags :

Ramol
Where is TTI_WARNING_LARGE ?
Where is TTI_WARNING_LARGE define? If I use TTI_WARNING_LARGE I have compile error error C2065: 'TTI_WARNING_LARGE' : undeclared identifier
I didn't find TTI_WARNING_LARGE in the file commctrl.h. there only defined following constant

// ToolTip Icons possible wParam values for TTM_SETTITLE message
#define TTI_NONE 0
#define TTI_INFO 1
#define TTI_WARNING 2
#define TTI_ERROR 3
// values larger thant TTI_ERROR are assumed to be an HICON value

Tags :

Raabi
Custom Icon
It seems custom icons on WinXP (SP3) only works with Common Controls V6. Without, space is reserved in the ToolTip but no icon is displayed at all.

@Ramol
PSDK header says:
// ToolTip Icons (Set with TTM_SETTITLE)
#define TTI_NONE 0
#define TTI_INFO 1
#define TTI_WARNING 2
#define TTI_ERROR 3
#if (_WIN32_WINNT >= 0x0600)
#define TTI_INFO_LARGE 4
#define TTI_WARNING_LARGE 5
#define TTI_ERROR_LARGE 6
#endif // (_WIN32_WINNT >= 0x0600)

that means lage icons on Vista or higher.
Tags :

Page view tracker