Capture Enter key press in EDIT Box
Hi all,
I'm rather new to win32 programming and am having a hard time trying to work out how to capture when the ENTER key has been pressed in an EDIT box.
My main window has a few controls on it:
- a listview
- 2 buttons
- an edit box
The edit box is a single line box that takes text and will search the listview for matching strings. One of the 2 buttons is a "Search" button and the other is a "Clear Search" button. My search functionality works but only when the "Search" button is pressed, but I want it so that if you type in some text in the edit box and press enter it will run the search function.
How do I catch when the enter key has been pressed in the edit box?
Do I catch a Windows event in my WindowProcedure() function?
Some of my code is:
Code:
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CREATE:
{
// some code to handle window create
}
case WM_COMMAND:
{
HANDLE_WM_COMMAND(hwnd, wParam, lParam, onCommand);
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
break;
}
default:
{
return DefWindowProc(hwnd, message, wParam, lParam);
}
}
return 0;
}
void onCommand(HWND hwnd, int id, HWND hCtl, UINT codeNotify)
{
switch(id)
{
case IDB_BUTTON:
{
switch (HIWORD(id))
{
case BN_CLICKED:
{
// handle "Search" button click, run search function
}
}
break;
}
}
Thanks in advance.