Win32 Edit Control Return Question

Started by
5 comments, last by Endurion 16 years, 10 months ago
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.
Advertisement
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.


..............
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]
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.
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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Hmm i see thank you for that answer.

I got docked some points for the question not being understod :(
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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement