Virtual Developer Workshop: Containerized Development with Docker
The CToolTipEx class is a extension of the MFC CToolTipCtrl control. When Microsoft c reated Internet Explorer 4, they also added many new functions and capabilities for CToolTipCtrl. Unfortunately, they have not added these to the CToolTipCtrl class yet. This class wraps all the new procedures in an easy to use and recognizable format.
Some of the new functions included:
- Ability to change the colors of both the background and foreground (text) of the Tooltip.
- Ability to change the margins (empty space) surrounding the Tooltip.
- Extended the SetDelayTime function to allow for changing the amount of time the Tooltip is visible and changing the amount of time before the Tooltip appears when moving the cursor to a new control.
- Ability to adjust the maximum width of the Tooltip. Anything bigger will be displayed on multiple lines.
- Ability for the Tooltip to move (track) with the cursor.
In your mainfrm.h add a variable for the tooltip:
In your mainfrm.cpp's OnCreate, after you create the ToolBar:
To access your tooltip control you must use:
_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
CToolTipEx* pToolTip = (CToolTipEx*) pThreadState->m_pToolTip;
The reason you must use the above two lines instead of CToolBarCtrl's GetToolTips() is that the Toolbar doesn't really own the tooltip. It is owned by the main application thread.
If you have any questions see the provided help file. It lists all the functions and gives examples for each.
Last updated: 9 May 1998