如何从CMFCRibbonColorComboBox
派生我的课程CMFCRibbonComboBox
并覆盖OnDrawDropListItem
?
如何在选择后为所选项目设置背景颜色。
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;
}
答案 0 :(得分:0)
CMFCRibbonComboBox
类源自CMFCRibbonEdit
,CMFCRibbonButton
派生自virtual COLORREF CMFCRibbonButton::OnFillBackground(CDC* pDC)
。据我所知,你需要覆盖{{1}}