CMFCRibbonColorComboBox 设置所选项目的背景颜色
CMFCRibbonColorComboBox set background color for selected Item
如何从 CMFCRibbonComboBox
导出我的 class CMFCRibbonColorComboBox
并覆盖 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;
}
CMFCRibbonComboBox
class 派生自 CMFCRibbonEdit
派生自 CMFCRibbonButton
。据我所知,您需要覆盖 virtual COLORREF CMFCRibbonButton::OnFillBackground(CDC* pDC)
如何从 CMFCRibbonComboBox
导出我的 class CMFCRibbonColorComboBox
并覆盖 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;
}
CMFCRibbonComboBox
class 派生自 CMFCRibbonEdit
派生自 CMFCRibbonButton
。据我所知,您需要覆盖 virtual COLORREF CMFCRibbonButton::OnFillBackground(CDC* pDC)