CMFC Ribbon Color ComboBox为所选项目设置背景颜色

时间:2015-04-16 12:52:50

标签: mfc ribbon-control

如何从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;
}

1 个答案:

答案 0 :(得分:0)

CMFCRibbonComboBox类源自CMFCRibbonEditCMFCRibbonButton派生自virtual COLORREF CMFCRibbonButton::OnFillBackground(CDC* pDC)。据我所知,你需要覆盖{{1}}