Check Boxes with Icons? |
Post Reply |
Author | |
mrmathis
Senior Member Joined: 17 May 2007 Location: United States Status: Offline Points: 105 |
Post Options
Thanks(0)
Posted: 19 March 2009 at 11:36am |
Is this picture possible? Check boxes with icons rather than text? If so, how can I do this?
|
|
--Mike
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hello,
not supported by deafult :( but you can always create class from CXTPControlCheckBox, override
virtual CSize GetSize(CDC* pDC);
and virtual void Draw(CDC* pDC);
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
mrmathis
Senior Member Joined: 17 May 2007 Location: United States Status: Offline Points: 105 |
Post Options
Thanks(0)
|
Thanks for the pointers. I have it working. Here's my class:
// draw checkboxes with icons instead of text class SECheckBoxWithIcon : public CXTPControlCheckBox { DECLARE_XTP_CONTROL(SECheckBoxWithIcon) public: SECheckBoxWithIcon() { } virtual CSize GetSize(CDC* pDC) { return(CSize(48,22)); } virtual void Draw(CDC* pDC) { // code lifted from CXTPPaintManager::DrawControlToolBarParent CXTPRibbonTheme* pTheme = dynamic_cast<CXTPRibbonTheme*>(GetPaintManager()); BOOL bPressed = GetPressed(), bSelected = GetSelected(), bEnabled = GetEnabled(), bChecked = GetChecked(), bPopuped = GetPopuped(); CRect rcButton = GetRect(); CSize szCheckBox = DrawControlCheckBoxMark(pTheme, pDC, rcButton, FALSE, bSelected, bPressed, bChecked, bEnabled); CRect rcCheck = CRect(CPoint(rcButton.left + 3, (rcButton.bottom + rcButton.top - szCheckBox.cy)/2), szCheckBox); DrawControlCheckBoxMark(pTheme, pDC, rcCheck, TRUE, bSelected, bPressed, bChecked, bEnabled); // draw the icon CPoint pt = CPoint(rcButton.left + szCheckBox.cx + 5, rcButton.top + 2); if (CXTPImageManagerIcon* pImage = GetImage()) { pImage->Draw(pDC, pt); } } // protected function lifted from Codejock for access here CSize /*CXTPRibbonTheme::*/DrawControlCheckBoxMark(CXTPRibbonTheme* pPaintManager, CDC* pDC, CRect rc, BOOL bDraw, BOOL bSelected, BOOL bPressed, BOOL bChecked, BOOL bEnabled) { if (!bDraw) return CSize(13, 13); CXTPOffice2007Image* pImage = pPaintManager->LoadImage(/*FormatName*/(_T("TOOLBARBUTTONCHECKBOX"))); ASSERT(pImage); if (!pImage) return CSize(13, 13); int nState = 0; if (!bEnabled) nState = 3; else if (bSelected && bPressed) nState = 2; else if (bSelected) nState = 1; if (bChecked == 1) nState += 4; if (bChecked == 2) nState += 8; pImage->DrawImage(pDC, rc, pImage->GetSource(nState, 12), CRect(0, 0, 0, 0)); return CSize(13, 13); } }; IMPLEMENT_XTP_CONTROL(SECheckBoxWithIcon, CXTPControlCheckBox) |
|
--Mike
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Thanks for sharing :)
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |