Article ID: 140595 - Last Review: December 2, 2003 - Revision: 2.0 DOC: How to Display Tool Tips After Calling EnableToolTipsThis article was previously published under Q140595 On This PageSUMMARY
The Microsoft Foundation Classes (MFC) 4.x documentation states that you
can call the CWnd::EnableToolTips function to enable tool tips for the
child controls of a window. For example, this function can be used to
display tool tips for all the controls on a Form View.
However, simply calling this function is not sufficient. In an application built with MFC 4.x, tool tips for your child controls will not display correctly unless you provide a handler for the TTN_NEEDTEXT tool tip notification. This documentation error has been fixed in Visual C++ version 5.0. MORE INFORMATION
The default tool tips provided for your windows by EnableToolTips do not
have text associated with them. In order to retrieve text for the tool tip
to display, the TTN_NEEDTEXT notification is sent to the tool tip control's
parent window just before the tool tip window is displayed. If there is no
handler for this message to assign some value to the pszText member of the
TOOLTIPTEXT structure, there will be no text displayed for the tool tip.
Tool tips are displayed for tool bar buttons without any extra effort. This is because the parent of the tool bar is derived from CFrameWnd, which has a default handler for the TTN_NEEDTEXT notification. This handler is designed for handling TTN_NEEDTEXT notifications from tool tip controls associated with tool bar buttons. This handler is not called when the notification is sent from a tool tip control associated with a child control in a window that is not a CFrameWnd such as a control on a dialog box or a form view. Therefore, it is necessary for the user to provide a handler function for the TTN_NEEDTEXT notification message in order to display tool tips for child controls. Steps to Enable Tool Tips for Child ControlsTo enable tool tips for the child controls of a window (such as the controls on a form view), follow these steps:
Sample CodeREFERENCES
For further information on how commands such as WM_NOTIFY are routed, see
Programming with MFC Overview, Working with Messages and Commands, How the
Framework Calls a Handler, Command Routing in Books Online.
For further information on how to handle a WM_NOTIFY message such as TTN_NEEDTEXT, see Tech Note 61: ON_NOTIFY and WM_NOTIFY Messages. APPLIES TO
| Article Translations
|

Back to the top
