I am trying to implement a dark mode for my application, by using DarkMode_Explorer / DarkMode_CFD etc. I have handled OnCtlColor
and set the theme using SetWindowTheme
.
If my CComboBoxEx
is a DropList
then it renderings properly. But when I set it to Downdown
it looks odd:


Using a standard CComboBox
renders properly for both modes.
I wanted to use the CComboBoxEx
because it made it easier to get at the edit control and set it as numeric. I realise I can do it old-style with CComboBox
. But it would be nice to continue using this control.
Steps to reproduce
- Add a
CComBoxEx
control to your dialog and set it as Dropdown
.
- Configure your application / dialog to use dark mode.
- Apply the theme to the combo:
pComboBoxEx->SetWindowTheme(theme);
auto pComboEdit = pComboBoxEx->GetEditCtrl();
if (pComboEdit && pComboEdit->GetSafeHwnd())
{
SetWindowTheme(pComboEdit->GetSafeHwnd(), L"DarkMode_CFD", nullptr);
}
// Get the underlying ComboBox control so that we can get the ListBox handle
auto pComboBox = pComboBoxEx->GetComboBoxCtrl();
if (pComboBox)
{
COMBOBOXINFO cbi{};
cbi.cbSize = sizeof(COMBOBOXINFO);
if (GetComboBoxInfo(pComboBox->GetSafeHwnd(), &cbi) && cbi.hwndList)
{
SetWindowTheme(cbi.hwndList, L"DarkMode_Explorer", nullptr);
// The scrollbars are now set correctly, but the ListBox background is still white.
}
}
- Handle
WM_CTLCOLOR
(I am including all I am using in my project):
const auto backColour = parentIsChild ? DarkModeTools::kDarkSheetBackgroundColor
: DarkModeTools::kDarkBackgroundColor;
switch (nCtlColor)
{
case CTLCOLOR_STATIC: // Static text
pDC->SetBkColor(backColour);
if (pControl->IsWindowEnabled())
{
pDC->SetTextColor(kDarkTextColor);
}
else
{
pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
}
break;
case CTLCOLOR_DLG: // Dialog background
case CTLCOLOR_SCROLLBAR: // Scrollbars
case CTLCOLOR_EDIT: // Edit control
case CTLCOLOR_LISTBOX: // Listbox
case CTLCOLOR_MSGBOX:
pDC->SetTextColor(kDarkTextColor);
pDC->SetBkColor(backColour);
break;
case CTLCOLOR_BTN: // Buttons
default:
// You can add specific cases here if needed
break;
}
Hat should be enough to replicate the issue.