file:///c:%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml - Oleg gave me some basic code that I customised to suit
my purposes. It would be nice if this code sample made it into the
samples.
file:///c:%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml - class
CControlComboBoxCustomDraw: public
CXTPControlComboBox, CXTPMarkupContext {
DECLARE_XTP_CONTROL(CControlComboBoxCustomDraw)
public:
CControlComboBoxCustomDraw(CXTPCommandBars*
pCommandBars = NULL)
{
GetCommandBar()->SetCommandBars(pCommandBars);
// Require to find Site.
ModifyListBoxStyle(0,
LBS_OWNERDRAWFIXED | LBS_HASSTRINGS);
}
void
DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); };
//////////////////////////////////////////////////////////////////////////
// CControlComboBoxCustomDraw
IMPLEMENT_XTP_CONTROL(CControlComboBoxCustomDraw,
CXTPControlComboBox)
void CControlComboBoxCustomDraw::DrawItem(
LPDRAWITEMSTRUCT lpDrawItemStruct ) {
CString
strText;
GetLBText(lpDrawItemStruct->itemID,
strText);
CRect
rc(&lpDrawItemStruct->rcItem);
ASSERT(lpDrawItemStruct->CtlType
== ODT_LISTBOX);
CDC* pDC =
CDC::FromHandle(lpDrawItemStruct->hDC);
BOOL bSelected
= lpDrawItemStruct->itemState & ODS_SELECTED;
CXTPPaintManager*
pPaintManager = GetPaintManager();
COLORREF
crOldTextColor =
pDC->SetTextColor(pPaintManager->GetRectangleTextColor(bSelected,
FALSE, TRUE, FALSE, FALSE, xtpBarTypePopup, xtpBarPopup));
if (bSelected)
pPaintManager->DrawRectangle(pDC,
rc, TRUE, FALSE, TRUE, FALSE, FALSE, xtpBarTypePopup, xtpBarPopup);
else
pDC->FillSolidRect(rc,
pPaintManager->GetXtremeColor(COLOR_WINDOW));
CString
strMarkup = _T("<TextBlock>") + strText +
_T("</TextBlock>");
CXTPMarkupUIElement*
pElement = XTPMarkupParseText(this, strMarkup);
if (pElement)
{
rc.left
+= 3;
XTPMarkupSetDefaultFont(this, 0, pDC->GetTextColor());
XTPMarkupRenderElement(pElement,
pDC->GetSafeHdc(), rc);
XTPMarkupReleaseElement(pElement);
}
}
|