[VC6 MFC]为什么使用CToolTipCtrl后,程序无法正常运行

我这个程序是一个对话框程序,一个计算器。

我先在 主对话框类的头文件 里加上这个代码:
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);
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-09-19
微软帮助里面有非常详细的示例和说明,你对照调整一下就可以了,不复制了

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网