From 81b8ceb3d98adaecc1738cc2f0336314253b4e6c Mon Sep 17 00:00:00 2001 From: Grayson Riffe Date: Fri, 12 Jun 2026 02:04:22 -0500 Subject: [PATCH] Fix DPI bug --- WatchfulEye/src/Application.cpp | 7 ++++--- WatchfulEye/src/Application.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WatchfulEye/src/Application.cpp b/WatchfulEye/src/Application.cpp index 9b46006..b2b7ec8 100644 --- a/WatchfulEye/src/Application.cpp +++ b/WatchfulEye/src/Application.cpp @@ -124,7 +124,8 @@ namespace watchfuleye { } case WM_DPICHANGED: { // Prevents the window from resizing because of DPI changes - app->sizeWindow(hWnd); + RECT* suggestedRECT = reinterpret_cast(lParam); + app->sizeWindow(hWnd, suggestedRECT->left, suggestedRECT->top); return 0; } @@ -300,10 +301,10 @@ namespace watchfuleye { return DefWindowProc(hWnd, msg, wParam, lParam); } - void Application::sizeWindow(const HWND& hWnd) { + void Application::sizeWindow(const HWND& hWnd, int newXPos, int newYPos) { RECT clientRect = { .right = WINDOW_WIDTH, .bottom = WINDOW_HEIGHT }; AdjustWindowRectExForDpi(&clientRect, WINDOW_STYLE, FALSE, EX_WINDOW_STYLE, GetDpiForWindow(hWnd)); - SetWindowPos(hWnd, nullptr, 0, 0, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top, SWP_NOZORDER | SWP_NOMOVE); + SetWindowPos(hWnd, nullptr, newXPos, newYPos, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top, SWP_NOZORDER); } void Application::createTrayIcon() { diff --git a/WatchfulEye/src/Application.h b/WatchfulEye/src/Application.h index 768a928..bd34c63 100644 --- a/WatchfulEye/src/Application.h +++ b/WatchfulEye/src/Application.h @@ -16,7 +16,7 @@ namespace watchfuleye { private: static LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - void sizeWindow(const HWND& hWnd); + void sizeWindow(const HWND& hWnd, int newXPos = 0, int newYPos = 0); void createTrayIcon();