How to capture Enter key in a dialog?
-
My problem is a simple one: I have a dialog box. A simple one, just two lines to fill. If I press enter/return, by default dialog closes as if I have pressed ok. I would like to capture the keyboard, and make my dialog move onto next items when enter is pressed. I tried the following, no success:
void CEditDlg::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { AfxMessageBox("KEYUP"); CDialog::OnKeyUp(nChar, nRepCnt, nFlags); } void CEditDlg::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { AfxMessageBox("CHAR"); CDialog::OnChar(nChar, nRepCnt, nFlags); }
------------------------------------------ Experience is the name every one gives to their mistakes. - Oscar Wilde Experience is one thing you can't get for nothing. - Oscar Wilde -
My problem is a simple one: I have a dialog box. A simple one, just two lines to fill. If I press enter/return, by default dialog closes as if I have pressed ok. I would like to capture the keyboard, and make my dialog move onto next items when enter is pressed. I tried the following, no success:
void CEditDlg::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { AfxMessageBox("KEYUP"); CDialog::OnKeyUp(nChar, nRepCnt, nFlags); } void CEditDlg::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { AfxMessageBox("CHAR"); CDialog::OnChar(nChar, nRepCnt, nFlags); }
------------------------------------------ Experience is the name every one gives to their mistakes. - Oscar Wilde Experience is one thing you can't get for nothing. - Oscar WildeI forgot to check the dialog template in resource editor X| I just changed "Default button" propoerty from OK to "Insert" button. ------------------------------------------ Experience is the name every one gives to their mistakes. -- Oscar Wilde Experience is one thing you can't get for nothing. -- Oscar Wilde