HOWTO: Display More Than 80 Characters in a ToolTip Control
ID: Q180646
|
The information in this article applies to:
-
Microsoft Win32 Software Development Kit (SDK)
-
Microsoft Windows 2000
SUMMARY
By default, the text displayed for an item in a tooltip control is limited
to 80 characters. In some instances, you may want to have the tooltip
display more than 80 characters.
MORE INFORMATION
To enable a tooltip control to display more than 80 characters, you need to
specify that the text is available on a callback basis by setting the
lpszText member of the TOOLINFO structure to LPSTR_TEXTCALLBACK when the
tool is added to the tooltip control with the TTM_ADDTOOL message. When
this is done, the tooltip control sends the parent window a WM_NOTIFY
message with the TTN_NEEDTEXT notification code.
The TTN_NEEDTEXT notification's lParam is the address of a NMTTDISPINFO
structure. One member of this structure is the szText member. szText is a
character buffer that can hold up to 80 characters. Another member of this
structure is the lpszText member that is the address of a character buffer
that contains the text for the tool. By default, lpszText points to szText.
When processing the TTN_NEEDTEXT notification, you can either copy the
desired text to szText or change lpszText so that it points to a buffer
other than szText. To allow the tooltip control to display more than 80
characters for a tool, you must set lpszText to point to a buffer that you
allocate (and that contains the desired text).
After returning from the TTN_NEEDTEXT notification, the tooltip control
allocates a buffer and copies the text into this new buffer. As a result,
you can reuse the buffer for each TTN_NEEDTEXT notification. The buffer
that you use must be a static, global, or dynamically-allocated buffer as
long as it exists after returning from the notification. The buffer cannot
be created on the stack because it will not be valid after returning from
the message.
Add the TTS_NOPREFIX style to the tooltip control. You must do this because
the tooltip control will limit the text length to 80 characters again when
the control removes the "&" characters.
Additional query words:
Keywords : kbCtrl kbNTOS400 kbWinOS2000 kbSDKWin32 kbToolTip kbGrpUser kbWinOS95 kbWinOS98
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbhowto