Hey how do you make a your callback WindowProc() function detect when you press the 'Enter Key' from a single-line Edit Control?
Hey how do you make a your callback WindowProc() function detect when you press the 'Enter Key' from a single-line Edit Control?
Its very insteresting......
You are able to detect 'Enter Key' pressed event on Edit control from within your WinMain() function while you takes messages through GetMessage(...) or PeekMessage(...) function.
You will get MSG structure through above two functions. MSG structure contains Window's handle and generated message. If message parameter of MSG structure is WM_KEYDOWN, wParam parameter of MSG structure is 13 and if hwnd parameter match with your edit control's handle then you can say that 'Enter Key' is pressed on Edit Control.
To make callback WindowProc() function detect when you press the 'Enter Key' from a single-line Edit Control, I will give my opinion after thinking on it.
Chintan R Naik
you need the ES_WANTRETURN and this only works with the ES_MULTILINE style.
Why do you need a single line edit?
Try changing the style to mutli line and not specifying the ES_AUTOVSCROLL style.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
If you really want to do this, a useful technique is subclassing. This program demonstrates it, and how to catch a few useful keys.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Nevermind I figured out a simpler one.
I had to opt for ES_MULTILINE though (but with no ES_AUTOVSCROLL).
Thanks anyway guysCode:LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_COMMAND: if(HIWORD(wParam) == EN_CHANGE && GetAsyncKeyState(13) == (-32767)) { MessageBox(hwnd, "The Enter key has been pressed", "ALERT", MB_OK); } return 0; default: DefWindowProc(hwnd, Message, wParam, lParam); return 0; } }
Last edited by Rez; 07-03-2003 at 11:11 PM.
if(HIWORD(wParam) == EN_CHANGE && GetAsyncKeyState(13) == (-32767)) {
MessageBox(hwnd, "The Enter key has been pressed", "ALERT", MB_OK);
I think in if() condition you will also have to check for edit control's handle. Because if you have more than 1 edit controls then how can you identify even for a particular edit control ??
So.....I think you will also have to compare first parameter of WndProc() function. (i.e. HWND hwnd)
Chintan R Naik
Look up Subclassing. Its better.
"What are you after - the vague post of the week award?" - Salem
IPv6 Ready.
Travel the world, meet interesting people...kill them.
Trying to fix or change something, only guaruntees and perpetuates its existence.
I don't know about angels, but it is fear that gives men wings.
The problem with wanting something is the fear of losing it, or never having it. The thought makes you weak.
E-Mail Xei