Msdn中,
About Tooltip Controls
Describes how tooltip controls work and how you create them.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb760250(v=vs.85).aspx
Using Tooltip Controls
This section contains examples that demonstrate how to create different types of tooltips.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb760252(v=vs.85).aspx
CToolTipCtrl一般用法步骤,只适用于窗口控件(如Button):
1. 类中添加成员变量 CToolTipCtrl m_tt。
2. 在文档视图工程的OnCreate(对话框工程的OnInitDialog)中(或者其他适当的位置),进行CtoolTipCtrl的初始化相关工作
m_tt.Create(this);
m_tt.Activate(TRUE);
3.向CToolTipCtrl中添加需要显示Tip的控件,并同时指定相应的显示字串。
m_tt.AddTool(pWnd,"string to display");
4. 重载父窗口的 BOOL PreTranslateMessage(MSG* pMsg) ,在函数中调用
m_tt.RelayEvent(pMsg)
CToolTipCtrl的通用方法,不仅适用于窗口类控件,还适用于Toolbar的按钮:
1)头文件中添加函数声明
afx_msg BOOL OnToolTip(UINT id,NMHDR *pNMHDR,LRESULT *pResult);
2)添加消息映射 ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTip)。
3)在文档视图工程的OnCreate(对话框工程的OnInitDialog)中(或者其他适当的位置),进行CtoolTipCtrl的初始化相关工作。
EnableToolTips(TRUE);
添加函数OnToolTip实现
以上内容整理自网络
参考:http://zhoumf1214.blog.163.com/blog/static/52419402009113014342690/