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;