Darkmode combo on statusbar panes

ChuckieAJ 311 Reputation points
2025-03-04T13:29:05.45+00:00

I have two regular CComboBox controls (dropdown list style), and I have superimposed them on two statusbar panes:

User's image

This is how I create one of the combo boxes:

void CChristianLifeMinistryEditorDlg::InitStatusBarPageBreakCombo()
{
	CFont* pFont = m_StatusBar.GetFont();
	CRect  rcPane;

	m_StatusBar.GetItemRect(to_underlying(EnumStatusBarPane::PageBreaks), &rcPane);
	rcPane.left += kStatusBarIconWidth;

	m_cbStatusBarPageBreaks.Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_DROPDOWNLIST,
		rcPane, &m_StatusBar, IDC_COMBO_STATUSBAR_PAGE_BREAKS);
	m_cbStatusBarPageBreaks.SetFont(pFont);

	if (IsUsingDarkMode())
	{
		DarkModeTools::ApplyThemeToControl(&m_cbStatusBarPageBreaks);
	}

	list<UINT> listIDs;
	listIDs.push_back(IDS_STR_PAGE_BREAK_NONE);
	listIDs.push_back(IDS_STR_PAGE_BREAK_1WEEK);
	listIDs.push_back(IDS_STR_PAGE_BREAK_2WEEKS);
	listIDs.push_back(IDS_STR_PAGE_BREAK_3WEEKS);
	listIDs.push_back(IDS_STR_PAGE_BREAK_4WEEKS);

	for (const UINT& uID : listIDs)
	{
		CString strPageBreakMode, strPageBreakComboText;
		VERIFY(strPageBreakMode.LoadString(uID));
		strPageBreakComboText.Format(IDS_TPL_PAGE_BREAKS, (LPCTSTR)strPageBreakMode);
		m_cbStatusBarPageBreaks.AddString(strPageBreakComboText);
	}
	m_cbStatusBarPageBreaks.SetCurSel(to_underlying(m_ePageBreakMode));

	CPngImage pngImage;
	LOAD_LIGHT_THEME_PNG(pngImage, IDB_PNG_PAGE_BREAKS);
	m_StatusBar.SetPaneIcon(to_underlying(EnumStatusBarPane::PageBreaks), pngImage);

}

As you can see, the statusbar is set as the parent. And the statusbar is owner draw.

Everything is fine, except when the droplist shows:

User's image

If I had the combo on the dialog as a resource it will colour properly because the OnCtrlColor handler is triggered. But for some reason things are not working for these combos.

As for theming, I use DarkMode_CFD for the combo and this for the drop-list:

			if (className == L"ComboBox")
			{
				COMBOBOXINFO cbi{};
				cbi.cbSize = sizeof(COMBOBOXINFO);
				if (GetComboBoxInfo(pControl->GetSafeHwnd(), &cbi) && cbi.hwndList)
				{
					SetWindowTheme(cbi.hwndList, szDarkMode_Explorer, nullptr);
				}
			}

Why doesn't it work for the droplist bits on my combos on the statusbar?

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,875 questions
{count} votes

Accepted answer
  1. Castorix31 87,706 Reputation points
    2025-03-04T16:05:00.53+00:00

    In C++/Win32, it works for me if I hancle WM_CTLCOLOR* messages in the StatusBar, which is the parent of ComboBox (I must subclass it with SetWindowSubclass)

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.