I am trying to get the specific key that's pressed when a editbox have
the focus or gets the focus.
I tried the WM_KEYDOWN/UP, but that isn't sent when a editbox have the
focus...
Why I am trying to get the key is because I want to display the key
(VK_) in the editbox even if its mouse key, alt, ctrl and so on.
I Googled for some help but couldn't find anything more than setting
up a hook(?) and use low level keyhook(?), but that's probably to
complicated for me so I ask here, is there a easier / better way to do
this?
The windows proceedure for controls is provided by Windows itself and each control does it's own thing with the messages and pass notification codes specific to that control to the parent window.
You cannot directly get the WM_XXXX messages as you are hoping to do - wihout
If you want to handle key presses when focus is in an edit control then add this to your message loop:
(I'm assuming that you named your MSG uMsg, and your window handle hWnd)
if (uMsg.message == WM_KEYDOWN) SendMessage (hWnd, WM_KEYDOWN, uMsg.wParam, uMsg.lParam);
Then just used the WM_KEYDOWN case statement in your window procedure function to do what you want to when a key is pressed.
some random dude, thx for the info, it works too...
But how do I identify that it is the editform that sends the wm_keydown? I probably can use getfocus(), but isn't that little bit ugly to use there?
Actually you may need to do something weird I did with my Squibbles game. When the window is dragged the game continues to run while the window is moved around. I acomplished this by inserting a InvalidateRect() just before returning 0 in the window procedure...be warned, this keeps the message pump running in the background even when an edit box or any other control is active......you can capture WM_KEYDOWN this way I believe and act on it.
some random dude, thx, I verify the editform in my WindowProcedure now, if I do it in the GetMessage () loop I still need to verify it later on in the WindowProcedure =)
right about the cpu power but if you control it the right way you should have no problems i believe. of course, there are still other ways, there is always a way :)