Sign in to follow this  
Jouei

Win32 Edit Control Return Question

Recommended Posts

I have a simple single line edit control. The play can enter in there name and then hit enter the problem is i have no clue as to how i would go about captureing the return key being hit when in the edit control so i know i can continue on with the program. Well hopefully thats understandable thanks ahead of time.

Share this post


Link to post
Share on other sites
hmm perhaphs my question was some how miss understood
The user puts there name in the edit control
and then hits return in a normal edit crontrol hitting the return key will do nothing.

what i want to know is how can i tell when the Enter key has been hit in an Edit control.


..............

Share this post


Link to post
Share on other sites
When you hit return, some keypressed(or something) message is sent.
Then you call function which checks if edit has focus, if it has, then proceed.

Edit: Of course you'll have to process the message somehow(i.e. in your mainloop)

[Edited by - zeeli on June 10, 2009 1:48:16 PM]

Share this post


Link to post
Share on other sites
The edit box is a WIN32 edit bot i used CreateWindowEx() to create it
For the most part this is kind of hard to explain i guess ok heres whats going on.

Theres a window and in it the user puts in text now when they hit enter in a win32 edit box it does not do anything no flags are sent no notifications. So i wouldnt know when the user has entered in there name unless they pressed another Window witch would be a button witch is what i want to avoid.

For instance the effect im looking for is like a form on the web when your in one of the fields like a text box for example you can hit enter and the form is submited.
Thats what i want to basicaly do but in a windows application you hitting enter wont do anything when your in a Win32 Edit control.

I need to know how to Get a response from the Edit control when the Return key is Pressed Aka Enter.

Share this post


Link to post
Share on other sites
You need to do subclassing. This means using SetWindowLong with GWL_WNDPROC and preprocessing the messages. In your replacement WindowProc you can check for WM_KEYDOWN/WM_KEYPRESSED and check for VK_RETURN.

There is a style ES_WANTRETURN but this only works on multiline edit controls.

Share this post


Link to post
Share on other sites
Hmm i see thank you for that answer.

I got docked some points for the question not being understod :(

Share this post


Link to post
Share on other sites
Forgot another possibility, works only with single line edits though: If you're on a dialog you can set the default button style on the ok button. If you press Enter on a dialog and you're not inside a multi line edit box the default button gets pushed.

Share this post


Link to post
Share on other sites

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