CTooltipManager Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CTooltipManager Class.

Maintains runtime information about tooltips. The CTooltipManager class is instantiated one time per application.

class CTooltipManager : public CObject  

Public Methods

NameDescription
CTooltipManager::CreateToolTipCreates a tooltip control for the specified Windows control type(s).
CTooltipManager::DeleteToolTipDeletes a tooltip control.
CTooltipManager::SetTooltipParamsCustomizes the visual appearance of the tooltip control for the specified Windows control type(s).
CTooltipManager::SetTooltipTextSets 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.

CObject

CTooltipManager

Header: afxtooltipmanager.h

Creates a tooltip control.

static BOOL CreateToolTip(
    CToolTipCtrl*& pToolTip,  
    CWnd* pWndParent,  
    UINT nType);

Parameters

[out] pToolTip
A reference to a tooltip pointer. It is set to point to the newly created tooltip when the function returns.

[in] pWndParent
Parent of the tooltip.

[in] nType
Type of the tooltip.

Return Value

Nonzero if a tooltip has been created successfully.

Remarks

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 typeControl categoryExample types
AFX_TOOLTIP_TYPE_BUTTONA button.CMFCButton
AFX_TOOLTIP_TYPE_CAPTIONBARA caption bar.CMFCCaptionBar
AFX_TOOLTIP_TYPE_DEFAULTAny control that does not fit another category.None.
AFX_TOOLTIP_TYPE_DOCKBARA dockable pane.CDockablePane
AFX_TOOLTIP_TYPE_EDITA text box.None.
AFX_TOOLTIP_TYPE_MINIFRAMEA miniframe.CPaneFrameWnd
AFX_TOOLTIP_TYPE_PLANNERA planner.None.
AFX_TOOLTIP_TYPE_RIBBONA ribbon bar.CMFCRibbonBar, CMFCRibbonPanelMenuBar
AFX_TOOLTIP_TYPE_TABA tab control.CMFCTabCtrl
AFX_TOOLTIP_TYPE_TOOLBARA toolbar.CMFCToolBar, CMFCPopupMenuBar
AFX_TOOLTIP_TYPE_TOOLBOXA toolbox.None.

Deletes a tooltip control.

static void DeleteToolTip(CToolTipCtrl*& pToolTip);

Parameters

[in, out] pToolTip
A reference to a pointer to a tooltip to be destroyed.

Remarks

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);

Parameters

[in] nTypes
Specifies control types.

[in] pRTC
Runtime class of custom tooltip.

[in] pParams
Tooltip parameters.

Remarks

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.

Example

The following example demonstrates how to use the SetTooltipParams method of the CTooltipManager class. This code snippet is part of the Draw Client sample.

	CMFCToolTipInfo params;
	params.m_bVislManagerTheme = TRUE;

	theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &params);

Sets the text and description for a tooltip.

static void SetTooltipText(
    TOOLINFO* pTI,  
    CToolTipCtrl* pToolTip,  
    UINT nType,  
    const CString strText,  
    LPCTSTR lpszDescr=NULL);

Parameters

[in] pTI
A pointer to a TOOLINFO object.

[in, out] pToolTip
A pointer to the tooltip control for which to set the text and description.

[in] nType
Specifies the type of control with which this tooltip is associated.

[in] strText
The text to set as the tooltip text.

[in] lpszDescr
A pointer to the tooltip description. Can be NULL.

Remarks

The value of nType must be the same value as the nType parameter of CTooltipManager::CreateToolTip when you created the tooltip.

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

void UpdateTooltips();

Remarks

Hierarchy Chart
Classes
CMFCToolTipCtrl Class
CMFCToolTipInfo Class

Show: