MFC添加提示

来源:互联网 发布:王珮瑜 冯蕴 知乎 编辑:程序博客网 时间:2024/04/30 09:41

dlg.h中添加


CToolTipCtrl m_openToolTip;
BOOL CMy4Dlg::PreTranslateMessage(MSG* pMsg) ;


dlg.cpp中添加


m_openToolTip.Create(this); 
     m_openToolTip.AddTool( GetDlgItem(IDOK), "这是个确定按钮" ); //更改ID及提示信息
  m_openToolTip.AddTool( GetDlgItem(IDCANCEL), "这是个退出按钮" );
     m_openToolTip.SetDelayTime(200);
     m_openToolTip.SetTipTextColor( RGB(0,0,255) );
     m_openToolTip.SetTipBkColor( RGB(255,255,255));
     m_openToolTip.Activate(TRUE);


在dlg.cpp中还要重写那个函数


BOOL CMy4Dlg::PreTranslateMessage(MSG* pMsg)
{
 // TODO: Add your specialized code here and/or call the base class
 switch(pMsg->message)
 {
    case WM_LBUTTONDOWN:
       case WM_LBUTTONUP:
       case WM_MOUSEMOVE:
       m_openToolTip.RelayEvent(pMsg);
 }
    return CDialog::PreTranslateMessage(pMsg);
}

原创粉丝点击