Print Page | Close Window

Markup in CXTPControlComboBox

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=16594
Printed Date: 20 June 2025 at 5:50pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Markup in CXTPControlComboBox
Posted By: scottp
Subject: Markup in CXTPControlComboBox
Date Posted: 15 April 2010 at 8:19am
Hi,

is it possible to use (simple) markup in a CXTPControlComboBox on a toolbar?

I just want to add an icon to each item and make some items italic

thanks,

scott



Replies:
Posted By: mgampi
Date Posted: 13 May 2010 at 4:14pm
Hi;

I'm also interrested in using markup in plain CComboBox or CComboBoxEx.
How can this be achieved?


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: scottp
Date Posted: 28 May 2010 at 4:38am

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);
      }
     
}



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net