LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_ENTERSIZEMOVE:
    case WM_EXITSIZEMOVE:
        return 0;

    case WM_SYSCOMMAND:
        switch (wParam)
        {
        case SC_SCREENSAVE:
        case SC_MONITORPOWER:
        case SC_KEYMENU:
            return 0;
        }
        break;

    case WM_CLOSE:
        PostQuitMessage(0);
        return 0;

    case WM_KEYDOWN:
        callKeyEventHandler(wParam, true);
        break;

    case WM_KEYUP:
        callKeyEventHandler(wParam, false);
        break;

    case WM_SYSKEYDOWN:
        if (wParam == VK_MENU)
        {
            callKeyEventHandler(VK_MENU, true);
        }
        else if (GetKeyState(VK_F10) < 0)
        {
            callKeyEventHandler(VK_F10, true);
        }
        break;

    case WM_SYSKEYUP:
        if (wParam == VK_MENU)
        {
            callKeyEventHandler(VK_MENU, false);
        }
        else if (GetKeyState(VK_F10) >= 0) // TODO
        {
            callKeyEventHandler(VK_F10, false);
        }
        break;

    case WM_LBUTTONDOWN:
        SetCapture(hWnd);
        callKeyEventHandler(VK_LBUTTON, true);
        break;

    case WM_LBUTTONUP:
        ReleaseCapture();
        callKeyEventHandler(VK_LBUTTON, false);
        break;

    case WM_MBUTTONDOWN:
        SetCapture(hWnd);
        callKeyEventHandler(VK_MBUTTON, true);
        break;

    case WM_MBUTTONUP:
        ReleaseCapture();
        callKeyEventHandler(VK_MBUTTON, false);
        break;

    case WM_RBUTTONDOWN:
        SetCapture(hWnd);
        callKeyEventHandler(VK_RBUTTON, true);
        break;

    case WM_RBUTTONUP:
        ReleaseCapture();
        callKeyEventHandler(VK_RBUTTON, false);
        break;

    case WM_MOUSEWHEEL:
        if (static_cast<short>(HIWORD(wParam)) > 0)
        {
            (*s_key_event_handler)(ckKeyMgr::KEY_WHEELUP, true);
        }
        else
        {
            (*s_key_event_handler)(ckKeyMgr::KEY_WHEELDOWN, true);
        }
        break;
    }

    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Exemplo n.º 2
0
 JNIEXPORT void JNICALL Java_com_furseal_FursealView_nativeOnKeyUp(JNIEnv*, jobject, jint key_code)
 {
     callKeyEventHandler(static_cast<s16>(key_code), false);
 }