X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c905c0d60f4bd407cc4cbfd809d5cf8a51a61523..950905affdfa9041316f82308e1a11e82c783070:/src/msw/combo.cpp diff --git a/src/msw/combo.cpp b/src/msw/combo.cpp index c02a3ee345..3ddde4f0af 100644 --- a/src/msw/combo.cpp +++ b/src/msw/combo.cpp @@ -216,22 +216,36 @@ wxComboCtrl::~wxComboCtrl() void wxComboCtrl::OnThemeChange() { - wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive(); + // there doesn't seem to be any way to get the text colour using themes + // API: TMT_TEXTCOLOR doesn't work neither for EDIT nor COMBOBOX + SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); + + wxUxThemeEngine * const theme = wxUxThemeEngine::GetIfActive(); if ( theme ) { - wxUxThemeHandle hTheme(this, L"COMBOBOX"); - + // NB: use EDIT, not COMBOBOX (the latter works in XP but not Vista) + wxUxThemeHandle hTheme(this, L"EDIT"); COLORREF col; - theme->GetThemeColor(hTheme,EP_EDITTEXT,ETS_NORMAL,TMT_FILLCOLOR,&col); - SetBackgroundColour(wxRGBToColour(col)); - theme->GetThemeColor(hTheme,EP_EDITTEXT,ETS_NORMAL,TMT_TEXTCOLOR,&col); - SetForegroundColour(wxRGBToColour(col)); - } - else - { - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); + HRESULT hr = theme->GetThemeColor + ( + hTheme, + EP_EDITTEXT, + ETS_NORMAL, + TMT_FILLCOLOR, + &col + ); + if ( SUCCEEDED(hr) ) + { + SetBackgroundColour(wxRGBToColour(col)); + + // skip the call below + return; + } + + wxLogApiError(_T("GetThemeColor(EDIT, ETS_NORMAL, TMT_FILLCOLOR)"), hr); } + + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); } void wxComboCtrl::OnResize()