一个DLG 一个Toolbar  当鼠标移动到菜单栏时候 提示按钮信息Toolbar  ID: IDR_TOOLBAR1
Toolbar 上按钮 ID:IDC_BUTTON1
CToolTipCtrl   m_ToolTips;    //声明
BOOL CDLGDlg::OnInitDialog()中写的这个
CButton   *pButton;   
pButton=(CButton   *)GetDlgItem(IDC_BUTTON1);   
m_ToolTips.Create(this);   
m_ToolTips.AddTool(pButton,"this is a BUTTON"); //这里断点 就出错PreTranslateMessage 消息中显示switch(pMsg->message)   
{   
case   WM_LBUTTONDOWN:   
case   WM_LBUTTONUP:   
case   WM_MOUSEMOVE:   
m_ToolTips.RelayEvent(pMsg);   
      }   
出错这样写

解决方案 »

  1.   

    class CMyDlg : public CDialog{……CToolTipCtrl m_tt;……} 2.      在这个对话框的OnInitDialog()函数里,添加黑体部分:BOOL CMyDlg::OnInitDialog(){……   EnableToolTips(TRUE);     m_tt.Create(this);     m_tt.Activate(TRUE);     m_tt.AddTool(GetDlgItem(IDC_BUTTON1),"这是一个按钮");       m_tt.SetTipTextColor(RGB(0,0,255)); //提示文字颜色,非必需         m_tt.SetDelayTime(150);    //出现提示前的延迟时间,非必需……}   3.重载对话框的PreTranslateMessage(MSG* pMsg)函数,添加黑体部分:BOOL CMyDlg::PreTranslateMessage(MSG* pMsg) {   m_tt.RelayEvent(pMsg);     return CDialog::PreTranslateMessage(pMsg);}