diff --git a/include/wx/msw/stattext.h b/include/wx/msw/stattext.h index 11723ab6cf..863a02f56b 100644 --- a/include/wx/msw/stattext.h +++ b/include/wx/msw/stattext.h @@ -57,8 +57,6 @@ protected: WXWPARAM wParam, WXLPARAM lParam) override; - virtual void MSWSetDarkOrLightMode(SetMode setmode) override; - virtual wxString WXGetVisibleLabel() const override; virtual void WXSetVisibleLabel(const wxString& str) override; diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 36f25d21ea..c57e750d2d 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -271,8 +271,9 @@ void wxNotebook::MSWSetDarkOrLightMode(SetMode setmode) { wxNotebookBase::MSWSetDarkOrLightMode(setmode); - // Background must always be set. - SetBackgroundColour(GetDefaultAttributes().colBg); + // Background must always be set, unless there is a custom colour. + if ( !m_hasBgCol ) + m_backgroundColour = GetDefaultAttributes().colBg; } int wxNotebook::MSWGetToolTipMessage() const @@ -1344,14 +1345,6 @@ void wxNotebook::MSWNotebookPaint() void wxNotebook::OnPaint(wxPaintEvent& event) { - // We can rely on the default implementation if we don't have a custom - // background colour (note that it is always set when using dark mode). - if ( !m_hasBgCol ) - { - event.Skip(); - return; - } - if ( wxMSWDarkMode::IsActive() ) { // We can't use default painting in dark mode, it just doesn't work @@ -1360,6 +1353,14 @@ void wxNotebook::OnPaint(wxPaintEvent& event) return; } + // We can rely on the default implementation if we don't have a custom + // background colour. + if ( !m_hasBgCol ) + { + event.Skip(); + return; + } + wxPaintDC dc(this); RECT rc; diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 85fe0ead71..377186fa69 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -214,16 +214,6 @@ wxStaticText::MSWHandleMessage(WXLRESULT *result, return false; } -void wxStaticText::MSWSetDarkOrLightMode(SetMode setmode) -{ - wxStaticTextBase::MSWSetDarkOrLightMode(setmode); - - // When switching to light mode, the text color remains the same. We must - // explicitly update the color. - if ( setmode == SetMode::Change ) - SetForegroundColour(GetDefaultAttributes().colFg); -} - void wxStaticText::SetLabel(const wxString& label) { // If the label doesn't really change, avoid flicker by not doing anything.