1:创建对象
CToolTipCtrl m_toolTip;
EnableToolTips(TRUE);
m_toolTip.Create(this);
m_toolTip.Activate(TRUE);
2:注册,以一个按钮为例
CButton *pButton = (CButton*)GetDlgItem(IDC_BUTTON1);
m_toolTip.AddTool(pButton,_T("矩形") );
3:重载pretranslatemassage
添加 m_toolTip.RelayEvent(pMsg); // Passes a mouse message to a tool tip control for processing.
以上是最简便的功能实现,具体参照MSDN
To create and manipulate a CToolTipCtrl
Construct the CToolTipCtrl object.
Call Create to create the Windows tool tip common control and attach it to the CToolTipCtrl object.
Call AddTool to register a tool with the tool tip control, so that the information stored in the tool tip is displayed when the cursor is on the tool.
Call SetToolInfo to set the information that a tool tip maintains for a tool.
Call SetToolRect to set a new bounding rectangle for a tool.
Call HitTest to test a point to determine whether it is within the bounding rectangle of the given tool and, if so, retrieve information about the tool.
Call GetToolCount to retrieve a count of the tools registered with the tool tip control.