There are two solutions to solve this problem.
1. Catch the message for inputting these key.
BOOL CTestDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) // in case of ENTER key
pMsg->wParam = 1;
if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) // in case of ESC key
pMsg->wParam = 1;
return CDialog::PreTranslateMessage(pMsg);
}
2. Override OnOK() and OnCancel().
In the head file,
private:
virtual void OnOK(){}
virtual void OnCancel(){}
No comments:
Post a Comment