diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp index 41f652b79..9c512b055 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp @@ -45,15 +45,21 @@ void ColourPopup::create(int dialogID) display(); } -void ColourPopup::createForDpi(int dialogID) +void ColourPopup::doDialog(POINT p) { - const DPI_AWARENESS_CONTEXT dpiContextSystem = NppDarkMode::isWindows10() ? DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED : DPI_AWARENESS_CONTEXT_SYSTEM_AWARE; - const auto dpiContext = DPIManagerV2::setThreadDpiAwarenessContext(dpiContextSystem); - create(dialogID); - if (dpiContext != NULL) + if (!isCreated()) { - DPIManagerV2::setThreadDpiAwarenessContext(dpiContext); + const DPI_AWARENESS_CONTEXT dpiContextSystem = NppDarkMode::isWindows10() ? DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED : DPI_AWARENESS_CONTEXT_SYSTEM_AWARE; + const auto dpiContext = DPIManagerV2::setThreadDpiAwarenessContext(dpiContextSystem); + + create(IDD_COLOUR_POPUP); + + if (dpiContext != NULL) + { + DPIManagerV2::setThreadDpiAwarenessContext(dpiContext); + } } + ::SetWindowPos(_hSelf, HWND_TOP, p.x, p.y, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); } intptr_t CALLBACK ColourPopup::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.h b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.h index 6d125e035..77a1f932f 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.h +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.h @@ -37,14 +37,7 @@ public : } void create(int dialogID); - void createForDpi(int dialogID); - - void doDialog(POINT p) - { - if (!isCreated()) - createForDpi(IDD_COLOUR_POPUP); - ::SetWindowPos(_hSelf, HWND_TOP, p.x, p.y, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); - } + void doDialog(POINT p); virtual void destroy() { diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp index f8dc85670..6d2d793d2 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp @@ -263,16 +263,6 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent) ::SendMessage(msgDestParent ? _hParent : (::GetParent(_hParent)), NPPM_MODELESSDIALOG, MODELESSDIALOGADD, reinterpret_cast(_hSelf)); } -void StaticDialog::createForDpi(int dialogID, bool isRTL, bool msgDestParent, DPI_AWARENESS_CONTEXT dpiAContext) -{ - const auto dpiContext = setThreadDpiAwarenessContext(dpiAContext); - create(dialogID, isRTL, msgDestParent); - if (dpiContext != NULL) - { - setThreadDpiAwarenessContext(dpiContext); - } -} - intptr_t CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h index 4c36f04af..de3a8f290 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h @@ -44,7 +44,6 @@ public : virtual ~StaticDialog(); virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true); - virtual void createForDpi(int dialogID, bool isRTL = false, bool msgDestParent = true, DPI_AWARENESS_CONTEXT dpiAContext = DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); virtual bool isCreated() const { return (_hSelf != nullptr);