From bd26423cb642aa6e01ad06398ed36aa0a0ae6ffb Mon Sep 17 00:00:00 2001 From: Nanako <469449812@qq.com> Date: Fri, 4 Apr 2025 15:21:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8GET=5FX=5FLPARAM=E5=92=8CGET?= =?UTF-8?q?=5FY=5FLPARAM=E5=AE=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform_window/windows/windows_window.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/mirage_render/src/platform_window/windows/windows_window.cpp b/src/mirage_render/src/platform_window/windows/windows_window.cpp index 5d9f69a..54a48aa 100644 --- a/src/mirage_render/src/platform_window/windows/windows_window.cpp +++ b/src/mirage_render/src/platform_window/windows/windows_window.cpp @@ -3,6 +3,7 @@ #include "platform_window/platform_window.h" #include <windows.h> +#include <windowsx.h> #define WINDOW_HANDLE static_cast<HWND>(window_handle_) @@ -40,14 +41,14 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) // 窗口移动事件 if (uMsg == WM_MOVE) { - if (const auto window = get_window_from_hwnd(hwnd)) { window->on_move(LOWORD(lParam), HIWORD(lParam)); } + if (const auto window = get_window_from_hwnd(hwnd)) { window->on_move(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); } processed = true; } // 窗口大小改变事件 if (uMsg == WM_SIZE) { if (const auto window = get_window_from_hwnd(hwnd)) { - window->on_resize(LOWORD(lParam), HIWORD(lParam)); + window->on_resize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); } processed = true; } @@ -55,8 +56,8 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) // 鼠标移动事件 if (uMsg == WM_MOUSEMOVE) { if (const auto window = get_window_from_hwnd(hwnd)) { - const int x = LOWORD(lParam); - const int y = HIWORD(lParam); + const int x = GET_X_LPARAM(lParam); + const int y = GET_Y_LPARAM(lParam); const Eigen::Vector2f pos(static_cast<float>(x), static_cast<float>(y)); window->handle_mouse_move(pos); } @@ -77,8 +78,8 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) const auto x_button = uMsg >= WM_XBUTTONDOWN && uMsg <= WM_XBUTTONDBLCLK; if (lmr_button || x_button) { if (const auto window = get_window_from_hwnd(hwnd)) { - const int x = LOWORD(lParam); - const int y = HIWORD(lParam); + const int x = GET_X_LPARAM(lParam); + const int y = GET_Y_LPARAM(lParam); const Eigen::Vector2f pos(static_cast<float>(x), static_cast<float>(y)); const auto action = platform_event_to_mouse_action(uMsg, wParam); const auto button = platform_event_to_mouse_button(uMsg, wParam); @@ -95,8 +96,8 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) // 鼠标滚轮事件 if (uMsg == WM_MOUSEWHEEL || uMsg == WM_MOUSEHWHEEL) { if (const auto window = get_window_from_hwnd(hwnd)) { - const int x = LOWORD(lParam); - const int y = HIWORD(lParam); + const int x = GET_X_LPARAM(lParam); + const int y = GET_Y_LPARAM(lParam); POINT screen_point = { x, y }; ScreenToClient(hwnd, &screen_point);