我想在编辑框中处理回车键,How to do it?

解决方案 »

  1.   

    派生CEdit的子类或在PreTranlateMessage中处理
    if(pMsg->hwnd==GetDlgItem(IDC_EDITCTRL)->GetSafeHwnd() && pMsg->message==WM_KEYDWON)
    {
    ....
    }
      

  2.   

    BOOL CTest6Dlg::PreTranslateMessage(MSG* pMsg) 
    {
    if( pMsg->message == WM_KEYDOWN )

    if(pMsg->hwnd == GetDlgItem(IDC_EDIT1)->m_hWnd)
    {
    switch( pMsg->wParam )
    {
    case VK_RETURN:
    AfxMessageBox("enter");
    return TRUE;
    case VK_ESCAPE:
    AfxMessageBox("esc");
    return TRUE;
    }
    }
    return CDialog::PreTranslateMessage(pMsg);
    }