From e068efbc149d6fadfbe43b85dae6f12c66688a69 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 6 Oct 2025 22:33:14 +0200 Subject: [PATCH] Fix wxTextCtrl::SetFont() with wxTE_RICH when in dark mode Explicitly set the correct (for dark mode) colours when setting the new style, otherwise the control would use black text on almost black background. See #25856. --- src/msw/textctrl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 96225f19f8..3ffacce605 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -3131,6 +3131,15 @@ bool wxTextCtrl::SetFont(const wxFont& font) // the default font for it. wxTextAttr attr; attr.SetFont(font); + + // In dark mode we also need to set the colours explicitly, just as we + // do for the colours of the control itself in Create(). + if ( wxMSWDarkMode::IsActive() ) + { + attr.SetTextColour(GetForegroundColour()); + attr.SetBackgroundColour(GetBackgroundColour()); + } + SetStyle(-1, -1, attr); }