[英]Win32 Keyboard combination
I need to combine the Alt + (Left Arrow, Right Arrow, Up Arrow, Down Arrow) keys to move the window in Win32.我需要组合 Alt +(向左箭头、向右箭头、向上箭头、向下箭头)键在 Win32 中移动窗口。
Something like this, maybe?像这样的东西,也许?
case WM_KEYDOWN:
{
if (GetKeyState(VK_MENU) < 0 && GetKeyState(VK_UP) < 0) {
}
}
How can I do it?我该怎么做?
You should use the GetKeyState function during the processing of WM_SYSKEYDOWN messages.您应该在处理 WM_SYSKEYDOWN 消息期间使用 GetKeyState 函数。
case WM_SYSKEYDOWN:
{
if ( GetKeyState ( VK_MENU ) < 0 && GetKeyState ( VK_UP ) < 0 )
{
}
}
Note that VK_UP may come from Numeric Keypad while user is entering a character by its (uni)code position.请注意,当用户按(uni)代码位置输入字符时,VK_UP 可能来自数字键盘。 Expected behaviour on Windows is that numeric character input works independently to the NumLock state.
Windows 上的预期行为是数字字符输入独立于 NumLock 状态工作。 So you have to track this: React to Alt+Numpad input only after releasing Alt: If more than one key was entered so far, ignore it and let TranslateMessage() translate that to WM_CHAR (which is hopefully in your main message loop).
因此,您必须跟踪这一点:仅在释放 Alt 后才对 Alt+Numpad 输入做出反应:如果到目前为止输入了多个键,请忽略它并让 TranslateMessage() 将其转换为 WM_CHAR(希望在您的主消息循环中)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.