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();