如果你对按键的操作不太复杂的情况下,例如只是为了处理F5键,你可以在对话框类里的处理WM_KEYUP消息不就省事了。

解决方案 »

  1.   

    在对话框中的pretranslatemessage中截获wm_keydown消息,判断是f5,发出自定义消息
    调用自己的函数
      

  2.   

    我已经试过了WM_KEYDOUP/DOWN消息,结果还是不行,望请再予指点。
      

  3.   

    BOOL CTestDlg::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if(pMsg->message ==WM_KEYDOWN && ((int)pMsg->wParam)==VK_F5)
    {
    AfxMessageBox("F5 pressed");
    return TRUE; //不再处理,否则用FALSE
    }
    return CDialog::PreTranslateMessage(pMsg);
    }