PreTranslateMessage如何根据按钮caption进行消息拦截

lklwlklw 2009-10-14 11:35:59
如何改下面代码
BOOL CSearchuserDlg::PreTranslateMessage(MSG* pMsg)
{

if(pMsg->message==WM_LBUTTONUP) //判断是否有按键按下
{
switch(pMsg->wParam)
{
case “压射”: //错误
//add handle code here

break;

//add handle code here

break;

default:

break;

}

}

}

...全文
88 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
AresEntice 2009-10-14
  • 打赏
  • 举报
回复
BOOL CTestDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class

BOOL bRet = CDialog::PreTranslateMessage(pMsg);

CString strCaption = _T("");

if (pMsg->message==WM_LBUTTONDOWN)
{
GetFocus()->GetWindowText(strCaption);

::MessageBox(NULL, strCaption, "Caption", MB_ICONINFORMATION);
}

if (_T("strXXX")=strCaption)
{
}else if (...)
{
}
...
return bRet;
}

这样会好点,已经本人测试 哈哈 给分分哦!
yayafu 2009-10-14
  • 打赏
  • 举报
回复
得到按钮标题不就能拦截了吗,标题用if啊,谁说的用switch啊
AresEntice 2009-10-14
  • 打赏
  • 举报
回复
CString strCaption = _T("");
GetDlgItem(pMsg->wParam)->GetWindowText(strCaption)
然后根据strCaption来判断即可 哈哈。。

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧