I want to switch the ENTER key with the SPACE key, I've tried the next, but it didn't work. Help :)
Thank you.Code:case WM_CHAR:
if (wParam==VK_RETURN) {
SendMessage(hwnd, WM_CHAR, VK_SPACE, 0);
return(0);
}
Printable View
I want to switch the ENTER key with the SPACE key, I've tried the next, but it didn't work. Help :)
Thank you.Code:case WM_CHAR:
if (wParam==VK_RETURN) {
SendMessage(hwnd, WM_CHAR, VK_SPACE, 0);
return(0);
}
Hmm.....well, that should work fine. Two things I can think of that might be causing your problem:
Have you defined the ES_WANTRETURN style in the creation of the edit control? If not, it's possible that WM_CHAR messages aren't being sent when the return key is pressed.
Is that all you have for the WM_CHAR case? Remember, you're sending a message to your own window. If you don't handle that message, nothing's going to happen. I don't see a default case that calls the default Edit Control procedure. (I assume you've subclassed the window?)
well actually the program is focused on a button.
what i am trying to do is allow the user to hit the button using ENTER instead of SPACE
please help...
I think VK_RETURN comes in on the WM_KEYDOWN message... try using case '\n': when handling the WM_CHAR message
no that's not the problem. the problem is with the SPACE send itself.
Is there a way to push the button, to make it do whatever it meant to do?Code:LRESULT CALLBACK MyButtonProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
if (Msg==WM_KEYDOWN)
if (wParam==VK_TAB) {
SetFocus(GetNextDlgTabItem(GetParent(hwnd), hwnd, 0));
return(0);
}
else if (wParam==VK_SPACE) {
MessageBox(NULL, "SPACE" , " ", 0);
return(0);
}
else if (wParam==VK_RETURN) {
MessageBox(NULL, "RETURN" , " ", 0);
SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, 0); // This line doesn't work, the space is not being send
return(0);
}
return CallWindowProc(OriginalButtonProc, hwnd, Msg, wParam, lParam);
}
well, the BM_CLICK did the trick, but the VK_SPACE didn't work, and the proc couldn't see it?