From f589441cbfaa5fdfb64a9972e2bce1278e5a8940 Mon Sep 17 00:00:00 2001 From: Shulga Konstantin Date: Tue, 15 Sep 2020 22:47:14 +0300 Subject: [PATCH] feat: add the ability to move the sprite using the mouse wheel --- Lab_1/Lab_1/Lab_1.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Lab_1/Lab_1/Lab_1.cpp b/Lab_1/Lab_1/Lab_1.cpp index 35b10aa..78e2049 100644 --- a/Lab_1/Lab_1/Lab_1.cpp +++ b/Lab_1/Lab_1/Lab_1.cpp @@ -309,6 +309,34 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; } break; + case WM_MOUSEWHEEL: + if (GET_KEYSTATE_WPARAM(wParam) == MK_SHIFT) + { + if (GET_WHEEL_DELTA_WPARAM(wParam) > 0) + { + spritePosition = CreateNewSpritePosition(spritePosition, CreateLeftSteps(), hWnd, sprite); + PostUpdateSpriteMessage(hWnd); + } + else + { + spritePosition = CreateNewSpritePosition(spritePosition, CreateRightSteps(), hWnd, sprite); + PostUpdateSpriteMessage(hWnd); + } + } + else + { + if (GET_WHEEL_DELTA_WPARAM(wParam) > 0) + { + spritePosition = CreateNewSpritePosition(spritePosition, CreateUpSteps(), hWnd, sprite); + PostUpdateSpriteMessage(hWnd); + } + else + { + spritePosition = CreateNewSpritePosition(spritePosition, CreateDownSteps(), hWnd, sprite); + PostUpdateSpriteMessage(hWnd); + } + } + break; case WM_SIZE: PostUpdateSpriteMessage(hWnd); return DefWindowProc(hWnd, message, wParam, lParam);