Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Too many WM_MOUSEWHEEL events issue

Too many WM_MOUSEWHEEL events issue

Scheduled Pinned Locked Moved C / C++ / MFC
helpoopquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tnarol
    wrote on last edited by
    #1

    Hi, My problem is that I sometimes receive dozens of WM_MOUSEWHEEL events for a single rotation step of the mouse wheel. Other events like WM_KEYDOWN don't have this problem, I received them only once for a pressed key. Normally I'm using this event in a CDialog inherited class and everything's works ok but the context here is slightly different. This time I had to create my window with "CreateWindowEx" so there's no CDialog inheritance and therefore I need to have my own message loop and message processing function. Can you have a look at them below and tell me if you see an explanation for my problem ? Thanks. Message loop : MSG msg; while (1) { PeekMessage(&msg, hWND, NULL, NULL, PM_REMOVE); TranslateMessage(&msg); DispatchMessage(&msg); if (msg.message == WM_QUIT) { break; } Sleep(100); } Message processing function : LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_CREATE: return 0; break; case WM_CLOSE: // windows is closing PostQuitMessage(0); return 0; break; case WM_DESTROY: PostQuitMessage(0); return 0; break; case WM_KEYDOWN: ProcessKeyStroke(MapVirtualKey(((UINT)lParam & 0x00ff0000) >> 16,1)); break; case WM_MOUSEWHEEL: { short zDelta = GET_WHEEL_DELTA_WPARAM(wParam); ProcessMouseWheel(zDelta); } break; default: return (DefWindowProc(hwnd, message, wParam, lParam)); break; } return 0; }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups