Too many WM_MOUSEWHEEL events issue
-
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; }