Neon
Neon

Reputation: 135

Win32 Keyboard combination

I need to combine the Alt + (Left Arrow, Right Arrow, Up Arrow, Down Arrow) keys to move the window in Win32.

Something like this, maybe?

case WM_KEYDOWN:
    {
        if (GetKeyState(VK_MENU) < 0 && GetKeyState(VK_UP) < 0) {
        }
    }

How can I do it?

Upvotes: 1

Views: 961

Answers (2)

Henrik Haftmann
Henrik Haftmann

Reputation: 71

Note that VK_UP may come from Numeric Keypad while user is entering a character by its (uni)code position. Expected behaviour on Windows is that numeric character input works independently to the NumLock state. 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).

Upvotes: 0

arturx64
arturx64

Reputation: 953

You should use the GetKeyState function during the processing of WM_SYSKEYDOWN messages.

case WM_SYSKEYDOWN:
{
    if ( GetKeyState ( VK_MENU ) < 0 && GetKeyState ( VK_UP ) < 0 )
    {

    }
}

Upvotes: 1

Related Questions