Keyboard Enter key not working in MFC Dialog Box ?
I have one MFC Login dialog box when I enter Username and password and hit Enter key the dialog box close down while when I use mouse to click on login it login's successfully.
What I need to do for making keyboard key work in MFC ?
in this case handle the enter key in the pretranslate() method of your db.
Implement the OnOK()
and/or the OnCancel()
methods and don't call the base methods there.
(those are virtual methods which you can simply overload).
Just because you removed the buttons doesn't mean you don't have to handle the events!
The OnOK()
is triggered by the Enter key, and OnCancel()
by the Escape key for dialogs.