怎么解决呢,我看了在编辑框的消息里没有处理鼠标的单击消息,有人说用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);
}可是没反应
我是在编辑框的的主窗口处理的不知道那里错了
{
// 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);
}可是没反应
我是在编辑框的的主窗口处理的不知道那里错了
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 对话框子类::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 对话框子类::PreTranslateMessage(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);
}
void CDlg_KcScan::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
ClientToScreen(&point);
CRect rcImage;
GetDlgItem(IDC_IMAGE)->GetClientRect(rcImage); //该函数检索指定的对话框中的控件句柄
GetDlgItem(IDC_IMAGE)->ClientToScreen(rcImage); if(rcImage.PtInRect(point))
{
CMenu Menu;
BOOL bRet = Menu.LoadMenu(IDR_MENUTCH);
if(bRet)
{
CPoint pt = point ;
Menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL,pt.x,pt.y,this);
Menu.DestroyMenu();
} }
CDialog::OnRButtonDown(nFlags, point);
}