读书人

MFC点击子对话框的编辑框弹出一个窗口

发布时间: 2012-08-28 12:37:01 作者: rapoo

MFC点击子对话框的编辑框弹出一个窗口
怎么解决呢,我看了在编辑框的消息里没有处理鼠标的单击消息,有人说用

BOOL CMyEdit::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message == WM_LBUTTONDOWN)
{
HWND hWnd = ::GetFocus();
int iID=::GetDlgCtrlID(hWnd);
if(iID==IDC_EDIT1)
{
AfxMessageBox(_T("1"));
}

else if(iID==IDC_EDIT2)
{
AfxMessageBox(_T("2"));


}

}
return CEdit::PreTranslateMessage(pMsg);
}

可是没反应
我是在编辑框的的主窗口处理的不知道那里错了

[解决办法]
请确保你其它的东西是对,PreTranslateMessage是对的!
BOOL CEditEx::PreTranslateMessage(MSG* pMsg)
{
// TODO: 在此添加专用代码和/或调用基类
if(pMsg->message == WM_LBUTTONDOWN || pMsg->message ==WM_CHAR)
{
HWND hWnd = ::GetFocus();
int iID=::GetDlgCtrlID(hWnd);
if(iID == IDC_EDIT1)
AfxMessageBox(_T("PPPPP"));
}
return CEdit::PreTranslateMessage(pMsg);
}
[解决办法]
BOOL CTtDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class

if (pMsg->message == WM_LBUTTONDOWN)
{
if (pMsg->hwnd == GetDlgItem(IDC_EDIT1)->m_hWnd)
{
TRACE("ddd\n");
}
}

return CDialog::PreTranslateMessage(pMsg);
}

读书人网 >VC/MFC

热点推荐