From 6c5f0009b4868616d74a33d98ec5b2e4cc85f25c Mon Sep 17 00:00:00 2001 From: ozone10 Date: Fri, 24 May 2024 19:03:28 +0200 Subject: [PATCH] Use gdi dpi scaling for Windows dialog - tweak dpi scaling for ColourPopup dialog. ref #14959 Close #15186 --- .../src/WinControls/ColourPicker/ColourPopup.cpp | 6 ++---- PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp index 9c512b055..9e6054521 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp @@ -49,8 +49,7 @@ void ColourPopup::doDialog(POINT p) { if (!isCreated()) { - const DPI_AWARENESS_CONTEXT dpiContextSystem = NppDarkMode::isWindows10() ? DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED : DPI_AWARENESS_CONTEXT_SYSTEM_AWARE; - const auto dpiContext = DPIManagerV2::setThreadDpiAwarenessContext(dpiContextSystem); + const auto dpiContext = DPIManagerV2::setThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED); create(IDD_COLOUR_POPUP); @@ -248,8 +247,7 @@ intptr_t CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM l display(false); - const DPI_AWARENESS_CONTEXT dpiContextSystem = NppDarkMode::isWindows10() ? DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED : DPI_AWARENESS_CONTEXT_SYSTEM_AWARE; - const auto dpiContext = DPIManagerV2::setThreadDpiAwarenessContext(dpiContextSystem); + const auto dpiContext = DPIManagerV2::setThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED); const bool isCreated = ChooseColor(&cc) == TRUE; if (dpiContext != NULL) { diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp index 52fec4dd2..f63aa2e2f 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp @@ -552,7 +552,15 @@ void WindowsDlg::updateButtonState() int WindowsDlg::doDialog() { - return static_cast(DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, dlgProc, reinterpret_cast(this))); + const auto dpiContext = DPIManagerV2::setThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED); + + int result = static_cast(DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, dlgProc, reinterpret_cast(this))); + + if (dpiContext != NULL) + { + DPIManagerV2::setThreadDpiAwarenessContext(dpiContext); + } + return result; } BOOL WindowsDlg::onInitDialog()