Fix DPI bug

This commit is contained in:
Grayson Riffe 2026-06-12 02:04:22 -05:00
parent f11b6abeec
commit 81b8ceb3d9
Signed by: grayson
SSH Key Fingerprint: SHA256:23HJg9tnL2m6u0uUb26QIrOTFymFZ+xgSH/2UPEBB/I
2 changed files with 5 additions and 4 deletions

View File

@ -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<RECT*>(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() {

View File

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