我这个程序是一个对话框程序,一个计算器。
我先在 主对话框类的头文件 里加上这个代码:
public:
CToolTipCtrl m_ToolTipCtrl;
然后在 主对话框类的实现文件 中的OnInitDialog()里加上如下代码(IDC_BTN_TUIGE是一个按钮):
if (m_ToolTipCtrl.Create(this,TTS_ALWAYSTIP) )
{
TRACE(_T("Unable To create ToolTip/n"));
return FALSE;
}
m_ToolTipCtrl.AddTool(GetDlgItem(IDC_BTN_TUIGE),"退格 从右边向左删除一个数字");
m_ToolTipCtrl.SetDelayTime(200);
m_ToolTipCtrl.SetTipTextColor(RGB(0,0,255));
m_ToolTipCtrl.SetTipBkColor(RGB(255,255,255));
m_ToolTipCtrl.Activate(TRUE);
最后,增加虚函数PreTranslateMessage(MSG* pMsg) ,写上代码:
if(pMsg->message== WM_LBUTTONDOWN || pMsg->message== WM_LBUTTONUP || pMsg->message== WM_MOUSEMOVE)
m_ToolTipCtrl.RelayEvent(pMsg);
return CDialog::PreTranslateMessage(pMsg);
点击那个“叹号”运行程序,可是好像没有运行,进程里面也没有。
我调试了一下程序,发现弹出一个消息框:
“Unhandled exception in JiSuan.exe (NTDLL.DLL): 0xC0000005: Access Violation.”
不知道是怎么回事。
请各位大神来指点一下。
断点调试,找到出问题的行。
BOOL xxxx::PreTranslateMessage(MSG* pMsg) //拦截回车消息{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message == WM_KEYDOWN)
if(int(pMsg->wParam) == VK_RETURN )
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
return CDialog::PreTranslateMessage(pMsg);
}