Not receiving WM_MOUSEWHEEL message

Viewed 59

I am not receiving the WM_MOUSEWHEEL (0x020E) message.

I have a simple example I programmed on C++:

#include <Windows.h>

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
    case WM_MOUSEHWHEEL:
        OutputDebugStringA("AAAA");
        break;
    case WM_CLOSE:
        PostQuitMessage(0);
        break;
    }
    return DefWindowProcA(hWnd, msg, wParam, lParam);
}

int CALLBACK WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR     lpCmdLine,
    int       nCmdShow) 
{
    const auto pClassName = "myWnd";
    WNDCLASSEXA wc = { 0 };
    wc.cbSize = sizeof(wc);
    wc.style = CS_OWNDC;
    wc.lpfnWndProc = WndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hInstance;
    wc.hIcon = nullptr;
    wc.hCursor = nullptr;
    wc.hbrBackground = nullptr;
    wc.lpszMenuName = nullptr;
    wc.lpszClassName = pClassName;
    wc.hIconSm = nullptr;
    RegisterClassExA(&wc);
    HWND hWnd = CreateWindowExA(
        0,
        pClassName,
        "Window",
        WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU,
        200, 200, 640, 480,
        nullptr, nullptr,
        hInstance, nullptr
    );
    ShowWindow(hWnd, SW_SHOW);
    MSG msg;
    while (GetMessageA(&msg, nullptr, 0, 0) > 0) {
        TranslateMessage(&msg);
        DispatchMessageA(&msg);
    }
    return 0;
}

I set a BreakPoint in Visual Studio on the case WM_MOUSEWHEEL: line. The BreakPoint is never reached.

I have already looked through other questions and the SetFocus or SetActiveWindow functions do not help.

0 Answers
Related