怎么解决呢,我看了在编辑框的消息里没有处理鼠标的单击消息,有人说用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);
}可是没反应
我是在编辑框的的主窗口处理的不知道那里错了

解决方案 »

  1.   

    使用你的东西测试是OK,重新写CEdit的过滤消息即可!
      

  2.   

    请确保你其它的东西是对,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);
    }
      

  3.   

    过滤子类怎么写
    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);
    }我写的是这样的上面是错的
      

  4.   

    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);
    }
      

  5.   

    我这有个类似的代码,不过是右键单击弹出菜单的,参考下
    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);
    }