Error WM_KEYDOWN

I'm trying to get my application to do something when the CTRL + S key is pressed. I just don't know how W and L params work for WM_KEYDOWN. MSDN has something about bit fields that I'm not sure about. How can I define CTRL and S? Thanks

What if the control other than hWnd has focus?

+7
c ++ winapi
source share
2 answers

Well, this one is a great list of virtual key codes.

CTRL-S will be sent after 2 WM_KEYDOWN messages - a message when the ctrl key is pressed ( VK_LCONTROL or VK_RCONTROL ), followed by 0x53 for the "S" key.

Instead of processing both messages, wait for the "S" key to be pressed, press " GetKeyState using the magic value VK_CONTROL (you will need to check the other for the left and right control keys individually) to see if the S key was pressed while holding the CTRL key .

-

Obviously, keyboard messages are sent directly to the focus window. To get accelerator combinations to work in the application area, you need to check the messages before sending them to the focus window - that is, in your message pump. See the documentation for TranslateAccelerator .

If you want to handle system keystrokes, another answer points to the api hotkey.

+16
source share

When WPARAM is CTK VKcode, set bool to the state of your object. Then, when S appears, if Ctrlbool, you have CTRL-S.

-2
source share

All Articles