原因:MFC在進行設計的時候,這兩個消息被對話框上的控件截獲了,不能到達消息響應函數。
1,在窗口類的聲明時添加一個虛函數:virtual BOOL PreTranslateMessage(MSG* pMsg);
2,在.cpp 中實現。
BOOL CCustomJobSetDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (WM_KEYDOWN == pMsg->message) {
if(!(GetKeyState(VK_SHIFT) < 0)) {
switch(pMsg->wParam) {
case VK_PRIOR:
case VK_NEXT:
case VK_END:
case VK_HOME:
case VK_LEFT:
case VK_UP:
case VK_RIGHT:
case VK_DOWN:
return 1;
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}