[Git][wxwidgets/wxwidgets][master] Fix background colour of combo boxes in wxMSW dark mode

1 view
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
Jul 9, 2025, 11:50:40 AMJul 9
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • a27fbc98
    by Vadim Zeitlin at 2025-07-09T17:35:45+02:00
    Fix background colour of combo boxes in wxMSW dark mode
    
    This was recently broken by 3ada94efeb (Also use control background in
    wxMSW dark mode, 2025-07-05), resulting in white background being used
    for wxChoice and wxComboBox as they incorrectly returned white as their
    background colour.
    
    Fix this by returning the correct colour in dark mode from
    wxChoice::GetClassDefaultAttributes() which is used as the fallback if
    background colour is not explicitly specified.
    
    See #25600.
    
    Closes #25619.
    

1 changed file:

Changes:

  • src/msw/choice.cpp
    ... ... @@ -195,11 +195,19 @@ wxChoice::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
    195 195
         // API: TMT_TEXTCOLOR doesn't work either for EDIT nor COMBOBOX
    
    196 196
         attrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
    
    197 197
     
    
    198
    -    // NB: use EDIT, not COMBOBOX (the latter works in XP but not Vista)
    
    199
    -    wxUxThemeHandle hTheme(wnd, L"EDIT");
    
    200
    -    attrs.colBg = hTheme.GetColour(EP_EDITTEXT, TMT_FILLCOLOR, ETS_NORMAL);
    
    201
    -    if ( !attrs.colBg.IsOk() )
    
    202
    -        attrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
    
    198
    +    if ( wxMSWDarkMode::IsActive() )
    
    199
    +    {
    
    200
    +        // Theme colour would be light, so don't use it.
    
    201
    +        attrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
    
    202
    +    }
    
    203
    +    else
    
    204
    +    {
    
    205
    +        // NB: use EDIT, not COMBOBOX (the latter works in XP but not Vista)
    
    206
    +        wxUxThemeHandle hTheme(wnd, L"EDIT");
    
    207
    +        attrs.colBg = hTheme.GetColour(EP_EDITTEXT, TMT_FILLCOLOR, ETS_NORMAL);
    
    208
    +        if ( !attrs.colBg.IsOk() )
    
    209
    +            attrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
    
    210
    +    }
    
    203 211
     
    
    204 212
         return attrs;
    
    205 213
     }
    


View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help Notification message regarding https://gitlab.com/wxwidgets/wxwidgets/-/commit/a27fbc98329c6928b9e24729c569f4ab91ac4515 at 1752076236

Reply all
Reply to author
Forward
0 new messages