1.成员函数中加入
CToolTipCtrl m_Mytip;
2.在initUpdate(初始化界面)中初始化:
m_Mytip.Create(this);
m_Mytip.AddTool( GetDlgItem(IDC_BUTTON), "你想要添加的提示信息" ); //IDC_BUTTON为你要添加提示信息的按钮的ID
m_Mytip.AddTool( GetDlgItem(IDC_BUTTON2), "你想要添加的提示信息2" ); //IDC_BUTTON2为你要添加提示信息的按钮的ID
m_Mytip.SetDelayTime(200); //设置延迟
m_Mytip.SetTipTextColor( RGB(0,0,255) ); //设置提示文本的颜色
m_Mytip.SetTipBkColor( RGB(255,255,255)); //设置提示框的背景颜色
m_Mytip.Activate(TRUE); //设置是否启用提示
3.在类向导中添加PreTranslateMessage函数
BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_MOUSEMOVE)
m_Mytip.RelayEvent(pMsg);
return CDialog::PreTranslateMessage(pMsg);
}
注:动条显示代码(未测试)
在静态显示的基础上,在要动态显示的地方加上:UpdateTipText函数,如下
CWnd* pW=GetDlgItem(IDC_CHECK1);//得到已添加tip控件
m_Mytip.UpdateTipText(L"new info",pW);//更新tip的内容