Sign in to follow this  

getting 'enter' keypress when edit box has focus

This topic is 4595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

One last question, and my dice server is done! OK: Say I have a dialog box, with one control in it, an edit box. I need to know how to capture, within the dialog box's CALLBACK routine, when the user presses enter, and then exit the dialog - like this: Dialog box is created User enters some value User presses enter -> Dialog box closes Think something like a search engines text box where you enter the keywords into. You don't have to press a button, you can just hit enter. I'm using C++ and win32 API. Thanks.

Share this post


Link to post
Share on other sites
no, that doesn't work. at least not when the edit control has focus, and I'm not sure if it would when it doesn't. And besides, the whole point is to be able to close it while the edit control has focus. Thanks, though.

Share this post


Link to post
Share on other sites
Ok, I'm getting tired.

Edit controls do not sent WM_NOTFIY messages. From what I understand, pressing the enter key on a single-line edit control performs the default action of the dialog box. The only thing that looked remotely useful was the EN_CHANGE notification, but I'm not certain of how that would be used.

jfl.

Share this post


Link to post
Share on other sites
Unless your Edit control doesn't have ES_WANTRETURN set pressing Enter will yield the same effect as pushing the default button of the dialog.
This will only work on a dialog (and using IsDialogMessage inside your message pump i think).
All you need to do is add the BS_DEFAULTBUTTON style to the button whose action you want to have done when pressing enter. No special message involved, it looks like a normal button press (WM_COMMAND).

Share this post


Link to post
Share on other sites

This topic is 4595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this