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); }
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); }
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
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?)
Code:void function(void) { function(); }
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
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
please help...
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
I think VK_RETURN comes in on the WM_KEYDOWN message... try using case '\n': when handling the WM_CHAR message
Last edited by The Brain; 07-03-2005 at 11:55 AM.
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
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); }
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
well, the BM_CLICK did the trick, but the VK_SPACE didn't work, and the proc couldn't see it?
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.