I have an edit box/window and when I press enter/return, I want it to clear the edit box/window, kind of like a command prompt. I would appreciate any help.
I have an edit box/window and when I press enter/return, I want it to clear the edit box/window, kind of like a command prompt. I would appreciate any help.
Look up the WM_SETTEXT message.
No, clearing the edit box is'nt the problem. The problem is doing it when one presses enter/return.
look up the WM_KEYDOWN message
"There are three kinds of people in the world...
Those that can count and those that can't."
I already know about the WM_KEYDOWN message.
How can inplement another message procedure for the edit box so that I can handle such messages as WM_KEYDOWN ?
Thanks in advance.
In your message switch, look for when enter is pressed. Then check which window has focus. If it is the edit, send a WM_SETEXT message with the info you want.
Ok, but how do you check which Window has focus?
GetFocus() returns the handle of the window that has focus. I bet you could have guessed that this is the function that you would use
WNDPROC OldEditProc;
LRESULT CALLBACK MyEditProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_KEYDOWN:
....
break;
}
return CallWindowProc (OldEditProc, hWnd, message, wParam, lParam);
}
You may process the keystrokes in your own wndproc, called here MyEditProc. The edit box must exist (hWndEdit is valid)
to do the subclass.
OldEditProc = (WNDPROC) SetWindowLong (hWndEdit, GWL_WNDPROC, (LONG) MyEditProc);