Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Markup in CXTPControlComboBox
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Markup in CXTPControlComboBox

 Post Reply Post Reply
Author
Message
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Topic: Markup in CXTPControlComboBox
    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
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Posted: 28 May 2010 at 4:38am

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.



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);
      }
     
}
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.