From 171d06b9b96318b4b3fa1ba9ffe8e6d62cee454a Mon Sep 17 00:00:00 2001 From: Raptox Date: Tue, 5 Nov 2024 17:22:23 +0100 Subject: [PATCH] Update DPI awareness context and handle WM_DPICHANGED for dynamic DPI adjustments --- Photino.Native/Photino.Windows.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Photino.Native/Photino.Windows.cpp b/Photino.Native/Photino.Windows.cpp index d364c28..c53feb1 100644 --- a/Photino.Native/Photino.Windows.cpp +++ b/Photino.Native/Photino.Windows.cpp @@ -69,7 +69,7 @@ void Photino::Register(HINSTANCE hInstance) RegisterClassEx(&wcx); - SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE); + SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); } Photino::Photino(PhotinoInitParams* initParams) @@ -333,6 +333,25 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } break; } + case WM_DPICHANGED: + { + UINT dpiX = HIWORD(wParam); + UINT dpiY = LOWORD(wParam); + + RECT* newWindowRect = (RECT*)lParam; + + SetWindowPos( + hwnd, + NULL, + newWindowRect->left, + newWindowRect->top, + newWindowRect->right - newWindowRect->left, + newWindowRect->bottom - newWindowRect->top, + SWP_NOZORDER | SWP_NOACTIVATE + ); + + return 0; + } case WM_SETTINGCHANGE: { if (IsColorSchemeChange(lParam))