Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Check Boxes with Icons?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Check Boxes with Icons?

 Post Reply Post Reply
Author
Message
mrmathis View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 May 2007
Location: United States
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mrmathis Quote  Post ReplyReply Direct Link To This Post Topic: Check Boxes with Icons?
    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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 20 March 2009 at 6:11am
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
Back to Top
mrmathis View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 May 2007
Location: United States
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mrmathis Quote  Post ReplyReply Direct Link To This Post Posted: 20 March 2009 at 2:19pm
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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 23 March 2009 at 1:58am
Thanks for sharing :)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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.223 seconds.