How to derive my class CMFCRibbonColorComboBox
from CMFCRibbonComboBox
and override OnDrawDropListItem
?
How I can set background color for selected item after selection.
BOOL CMFCRibbonColorComboBox::OnDrawDropListItem(CDC* pDC, int nIndex, CMFCToolBarMenuButton* pItem, BOOL bHighlight)
{
ASSERT_VALID(this);
CRect rc = pItem->Rect();
LPCTSTR lpszText = GetItem(nIndex);
if (lpszText == NULL)
{
return FALSE;
}
CString strText = lpszText;
pDC->DrawText(strText, rc, DT_SINGLELINE | DT_VCENTER);
return TRUE;
}
The CMFCRibbonComboBox
class is derived from CMFCRibbonEdit
which is derived from CMFCRibbonButton
. As far as I can tell you need to override virtual COLORREF CMFCRibbonButton::OnFillBackground(CDC* pDC)