BOOL CAaaDlg::PreTranslateMessage(MSG* pMsg) 
{
if(pMsg->hwnd == GetDlgItem(IDC_EDIT1)->m_hWnd){
if(pMsg->message == EN_SETFOCUS)//这儿怎么写?
int a = 5;
}
return CDialog::PreTranslateMessage(pMsg);
}

解决方案 »

  1.   

    BOOL   CAaaDlg::PreTranslateMessage(MSG*   pMsg)   

    if(pMsg-> message == WM_COMMAND && HIWORD(pMsg->wParam) == EN_SETFOCUS && LOWORD(pMsg->wParam) == IDC_EDIT1) 
    int   a   =   5; 
    } // ID和句柄要一个就行了
      

  2.   


    BOOL   CAaaDlg::PreTranslateMessage(MSG*   pMsg)   

    if(pMsg-> hwnd   ==   GetDlgItem(IDC_EDIT1)-> m_hWnd){ 
    //if(pMsg-> message   ==   EN_SETFOCUS)//这儿怎么写? 
    if(pMsg-> message   ==   WM_SETFOCUS)
    int   a   =   5; 

    return   CDialog::PreTranslateMessage(pMsg); 
    }
      

  3.   

    能否说说lParam参数包含的什么数据?
      

  4.   

    EN_SETFOCUS 
    idEditCtrl = (int) LOWORD(wParam); // identifier of edit control 
    wNotifyCode = HIWORD(wParam);      // notification code 
    hwndEditCtrl = (HWND) lParam;      // handle of edit control 
      

  5.   

    1楼的办法试过,不行呀.
    点击按钮进不去.没产生WM_COMMAND
      

  6.   

    1楼的办法试过,不行呀. 
    点击按钮进不去.没产生WM_COMMAND
    -----------------------------------
    你到底要怎样?按钮?编辑框?
    如果要点击按钮让编辑框得到焦点,先要KILL按钮的焦点,再给编辑框设焦点(可以发消息或SetFocus)。你没发消息,干等着,你以为消息会自己来。
      

  7.   

    非要在这里写吗?直接用CLASS_WIZARD里面不就有一个消息是EN_SETFOCUS吗?直接处理就可以了。
      

  8.   

    先要KILL按钮的焦点
    -----------------
    没KillFocus函数.
      

  9.   

    void CAaaDlg::OnButton8() 
    {
    CWnd *c = GetDlgItem(IDC_EDIT1);
    c->SetFocus();
    }BOOL CAaaDlg::PreTranslateMessage(MSG* pMsg) 
    {
    if(pMsg->message == WM_COMMAND){
            if(HIWORD(pMsg->wParam) == EN_SETFOCUS){
          a = IDC_EDIT1;
          if(LOWORD(pMsg->wParam) == IDC_EDIT1)
      a = 100;
    }
    } return CDialog::PreTranslateMessage(pMsg);
    }
      

  10.   

    随便放个按钮,再点它,都不能进入if(pMsg-> message   ==   WM_COMMAND){ 
    条件,怎么回事?
      

  11.   

    http://topic.csdn.net/t/20050621/02/4095439.html
      

  12.   

    比较 GetDlgItem() 与 GetFocus() 的返回。
      

  13.   

    比较   GetDlgItem()   与   GetFocus()   的返回。