Fix DPI bug
This commit is contained in:
parent
f11b6abeec
commit
81b8ceb3d9
@ -124,7 +124,8 @@ namespace watchfuleye {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WM_DPICHANGED: { // Prevents the window from resizing because of DPI changes
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,10 +301,10 @@ namespace watchfuleye {
|
|||||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
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 };
|
RECT clientRect = { .right = WINDOW_WIDTH, .bottom = WINDOW_HEIGHT };
|
||||||
AdjustWindowRectExForDpi(&clientRect, WINDOW_STYLE, FALSE, EX_WINDOW_STYLE, GetDpiForWindow(hWnd));
|
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() {
|
void Application::createTrayIcon() {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ namespace watchfuleye {
|
|||||||
private:
|
private:
|
||||||
static LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
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();
|
void createTrayIcon();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user