From 4227d13440c8da85ffeb8f178f01ebe0de71854b Mon Sep 17 00:00:00 2001 From: Steve Cornett <21205494+stevecor@users.noreply.github.com> Date: Thu, 6 Aug 2026 11:59:25 -0700 Subject: [PATCH] Fix wxTextCtrl border switching from dark mode Do not check dark mode in wxTextCtrl::CanApplyThemeBorder(). Instead, improve the checking for themed border drawing in the WM_NCPAINT handler. This fixed the border appearance after switching from dark mode to the light one. Closes #26794. --- src/msw/textctrl.cpp | 4 ++-- src/msw/window.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index ab79068637..7ea77849fa 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -496,8 +496,8 @@ bool wxTextCtrl::Create(wxWindow *parent, // returns true if the platform should explicitly apply a theme border bool wxTextCtrl::CanApplyThemeBorder() const { - // Standard text control already handles theming in light mode. - return IsRich() || wxMSWDarkMode::IsActive(); + // Standard text control already handles theming. + return IsRich(); } bool wxTextCtrl::MSWCreateText(const wxString& value, diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 900a632f1b..a4b8e1b5e0 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -3836,7 +3836,8 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result, { // Determine whether we should draw a border. bool drawBorder = false; - wxBorder border = DoTranslateBorder(GetBorder()); + wxBorder rawBorder = GetBorder(); + wxBorder border = DoTranslateBorder(rawBorder); switch ( border ) { case wxBORDER_THEME: @@ -3882,7 +3883,7 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result, rcClient.right, rcClient.bottom); // Draw the border. - if ( border == wxBORDER_THEME ) + if ( rawBorder == wxBORDER_THEME ) MSWDrawThemeBorder(hdc); else {