Keyboard Enter key not working in MFC Dialog Box?

2019-08-16 13:41发布

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 ?

2条回答
贪生不怕死
2楼-- · 2019-08-16 14:22

in this case handle the enter key in the pretranslate() method of your db.

查看更多
爷的心禁止访问
3楼-- · 2019-08-16 14:28

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.

查看更多
登录 后发表回答