description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: CTooltipManager Class |
CTooltipManager Class |
11/04/2016 |
|
|
c71779d7-8b6e-47ef-8500-d4552731fe86 |
Maintains runtime information about tooltips. The CTooltipManager
class is instantiated one time per application.
class CTooltipManager : public CObject
Name | Description |
---|---|
CTooltipManager::CreateToolTip | Creates a tooltip control for the specified Windows control type(s). |
CTooltipManager::DeleteToolTip | Deletes a tooltip control. |
CTooltipManager::SetTooltipParams | Customizes the visual appearance of the tooltip control for the specified Windows control type(s). |
CTooltipManager::SetTooltipText | Sets the text and description for a tooltip control. |
CTooltipManager::UpdateTooltips |
Use CMFCToolTipCtrl Class, CMFCToolTipInfo
, and CTooltipManager
together to implement customized tooltips in your application. For an example of how to use these tooltip classes, see the CMFCToolTipCtrl Class topic.
Header: afxtooltipmanager.h
Creates a tooltip control.
static BOOL CreateToolTip(
CToolTipCtrl*& pToolTip,
CWnd* pWndParent,
UINT nType);
pToolTip
[out] A reference to a tooltip pointer. It is set to point to the newly created tooltip when the function returns.
pWndParent
[in] Parent of the tooltip.
nType
[in] Type of the tooltip.
Nonzero if a tooltip has been created successfully.
You must call CTooltipManager::DeleteToolTip to delete the tooltip control that is passed back in pToolTip.
The CTooltipManager sets the visual display parameters of each tooltip it creates based on the tooltip type that nType specifies. To change the parameters for one or more tooltip types, call CTooltipManager::SetTooltipParams.
Valid tooltip types are listed in the following table:
Tooltip type | Control category | Example types |
---|---|---|
AFX_TOOLTIP_TYPE_BUTTON | A button. | CMFCButton |
AFX_TOOLTIP_TYPE_CAPTIONBAR | A caption bar. | CMFCCaptionBar |
AFX_TOOLTIP_TYPE_DEFAULT | Any control that does not fit another category. | None. |
AFX_TOOLTIP_TYPE_DOCKBAR | A dockable pane. | CDockablePane |
AFX_TOOLTIP_TYPE_EDIT | A text box. | None. |
AFX_TOOLTIP_TYPE_MINIFRAME | A miniframe. | CPaneFrameWnd |
AFX_TOOLTIP_TYPE_PLANNER | A planner. | None. |
AFX_TOOLTIP_TYPE_RIBBON | A ribbon bar. | CMFCRibbonBar, CMFCRibbonPanelMenuBar |
AFX_TOOLTIP_TYPE_TAB | A tab control. | CMFCTabCtrl |
AFX_TOOLTIP_TYPE_TOOLBAR | A toolbar. | CMFCToolBar, CMFCPopupMenuBar |
AFX_TOOLTIP_TYPE_TOOLBOX | A toolbox. | None. |
Deletes a tooltip control.
static void DeleteToolTip(CToolTipCtrl*& pToolTip);
pToolTip
[in, out] A reference to a pointer to a tooltip to be destroyed.
Call this method for each CToolTipCtrl Class that was created by CTooltipManager::CreateToolTip. The parent control should call this method from its OnDestroy
handler. This is required to correctly remove the tooltip from the framework. This method sets pToolTip to NULL before it returns.
Customizes the appearance of the tooltip control for the specified Windows control types.
void SetTooltipParams(
UINT nTypes,
CRuntimeClass* pRTC=RUNTIME_CLASS(CMFCToolTipCtrl),
CMFCToolTipInfo* pParams=NULL);
nTypes
[in] Specifies control types.
pRTC
[in] Runtime class of custom tooltip.
pParams
[in] Tooltip parameters.
This method sets the runtime class and initial parameters that the CToolTipManager uses when it creates tooltips. When a control calls CTooltipManager::CreateToolTip and passes in a tooltip type that is one of the types indicated by nTypes, the tooltip manager creates a tooltip control that is an instance of the runtime class specified by pRTC and passes the parameters specified by pParams to the new tooltip.
When you call this method, all existing tooltip owners receive the AFX_WM_UPDATETOOLTIPS message and they must re-create their tooltips by using CTooltipManager::CreateToolTip.
nTypes can be any combination of the valid tooltip types that CTooltipManager::CreateToolTip uses, or it can be AFX_TOOLTIP_TYPE_ALL. If you pass AFX_TOOLTIP_TYPE_ALL, all tooltip types are affected.
The following example demonstrates how to use the SetTooltipParams
method of the CTooltipManager
class. This code snippet is part of the Draw Client sample.
[!code-cppNVC_MFC_DrawClient#11]
Sets the text and description for a tooltip.
static void SetTooltipText(
TOOLINFO* pTI,
CToolTipCtrl* pToolTip,
UINT nType,
const CString strText,
LPCTSTR lpszDescr=NULL);
pTI
[in] A pointer to a TOOLINFO object.
pToolTip
[in, out] A pointer to the tooltip control for which to set the text and description.
nType
[in] Specifies the type of control with which this tooltip is associated.
strText
[in] The text to set as the tooltip text.
lpszDescr
[in] A pointer to the tooltip description. Can be NULL.
The value of nType must be the same value as the nType parameter of CTooltipManager::CreateToolTip when you created the tooltip.
For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.
void UpdateTooltips();
Hierarchy Chart
Classes
CMFCToolTipCtrl Class
CMFCToolTipInfo Class