int
CALLBACK
LockDlgProc(
    HWND        hDlg,
    UINT        Message,
    WPARAM      wParam,
    LPARAM      lParam)
{
    switch (Message)
    {
        case WM_INITDIALOG:
            CenterWindow(hDlg);
   return(TRUE);
        case WM_KEYDOWN:
        case WM_CHAR:
pWlxFuncs->WlxMessageBox(hGlobalWlx,NULL,TEXT("get  passwordmid"),TEXT("2222"),MB_OK);
   EndDialog(hDlg,WLX_SAS_TYPE_SC_INSERT);
   return TRUE;         default:
            return(FALSE);
}   }
为什么在该窗口中我按下键盘,不弹出MessageBox呢,WM_KEYDOWN,WM_CHAR怎么根本就没执行过。这是为什么??

解决方案 »

  1.   

    agree,BOOL CTest482Dlg::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE )
    {
    // OnKeyDown((UINT)pMsg->wParam,(UINT)pMsg->lParam,(UINT)pMsg->lParam);
    return TRUE;
    }
    return CDialog::PreTranslateMessage(pMsg);
    }
      

  2.   

    DispatchMessage always dispatches the message to the proper window; this is because each message in the queue is an MSG structure that contains the handle of the window to which the message belongs.也就是说DispatchMessage把按键的消息,传给了默认的对话框中相应控件的默认的消息处理函数了(也就是该控件的WndPrce去处理了),你应该重载这个控件的消息处理函数(WndPrce)才对