Jump to content
  • Advertisement
Sign in to follow this  
silverphyre673

getting 'enter' keypress when edit box has focus

This topic is 4935 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
Advertisement
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 tried googling for this, but msdn wasn't very helpful and a lot of the pages were in some oriental language... How would this look? Thanks.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!