diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index 4a0b13c8fd..b30c193d5c 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -1165,6 +1165,21 @@ inline wxLayoutDirection wxGetEditLayoutDirection(WXHWND hWnd) : wxLayout_LeftToRight; } +// Check if WM_SETTINGCHANGE notifies about the system colours change. +inline bool wxIsSystemColourChange(LPARAM lParam) +{ + // Note that "ImmersiveColorSet" is set both when switching between + // light and dark themes and also when changing high contrast mode, + // for which an additional message with "WindowsThemeElement" is + // also sent, but we don't need to check for it as handling this + // one is enough + if ( !lParam ) + return false; + + auto* const what = reinterpret_cast(lParam); + return wxStrcmp(what, wxT("ImmersiveColorSet")) == 0; +} + // ---------------------------------------------------------------------------- // functions mapping HWND to wxWindow // ---------------------------------------------------------------------------- diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 6c80a6f4c4..531cbe10c2 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -3566,12 +3566,7 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result, case WM_SETTINGCHANGE: // Check for the special case of the message which notifies about // the colours change. - // Note that "ImmersiveColorSet" is set both when switching between - // light and dark themes and also when changing high contrast mode, - // for which an additional message with "WindowsThemeElement" is - // also sent, but we don't need to check for it as handling this - // one is enough - if ( lParam && wxStrcmp((TCHAR*)lParam, wxT("ImmersiveColorSet")) == 0 ) + if ( wxIsSystemColourChange(lParam) ) processed = HandleSysColorChange(); else processed = HandleSettingChange(wParam, lParam);