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

OnDrawItemConstraint Question

 Post Reply Post Reply
Author
Message
Jay91 View Drop Down
Newbie
Newbie


Joined: 04 January 2006
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jay91 Quote  Post ReplyReply Direct Link To This Post Topic: OnDrawItemConstraint Question
    Posted: 04 January 2006 at 7:26am

Hello ..

I have some question for OnDrawItemConstraint

I want to make Color Combo Control using CXTPPropertyGridItem...and Insert color Rectangle and string for each of the combo list item..

In Sample source, make Combo list item using Bitpmap..but i have color rectangle too much  make Bitmap..

I see the manual, and find OnDrawItemConstraint... I think that it's suitable code....but don't Active...

How can i Make that Control using CXTPPropertyGridItem

Please Help me...!!!

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: 05 January 2006 at 2:21am

Hello,

Copy this code to your application:

class CPropertyGridItemColorList : public CXTPPropertyGridItemColor
{
public:
    CPropertyGridItemColorList(const CString& strCaption, COLORREF clr)
        : CXTPPropertyGridItemColor(strCaption, clr)
    {
        SetFlags(xtpGridItemHasComboButton | xtpGridItemHasEdit);
        GetConstraints()->AddConstraint(_T("Red"), RGB(0xFF, 0, 0));
        GetConstraints()->AddConstraint(_T("Green"), RGB(0, 0xFF, 0));
        GetConstraints()->AddConstraint(_T("Blue"), RGB(0, 0, 0xFF));
    }

    virtual void OnInplaceButtonDown()
    {
        CXTPPropertyGridItem::OnInplaceButtonDown();  &nbs p;    
    }

    virtual void OnValueChanged(CString strValue)
    {
        for (int i = 0; i < GetConstraints()->GetCount(); i++)
        {
             CXTPPropertyGridItemConstraint* pContstraint = GetConstraints()->GetConstraintAt(i);
             if (strValue == pContstraint->m_strConstraint)
             {
                 CXTPPropertyGridItemColor::OnValueChanged(RGBToString(pConts traint->m_dwData));
                 return;
             }
        }
        CXTPPropertyGridItemColor::OnValueChanged(strValue);
    }
   
    void OnDrawItemConstraint(CDC* pDC, CXTPPropertyGridItemConstraint* pConstraint, CRect rc, BOOL bSelected)
    {
        CRect rcColor(rc.left + 1, rc.top + 1, rc.left + 19, rc.bottom - 1);
        pDC->FillSolidRect(rcColor, pConstraint->m_dwData);
        pDC->Draw3dRect(rcColor, 0, 0);


        rc.left += 20;
        CXTPPropertyGridItemColor::OnDrawItemConstraint(pDC, pConstraint, rc, bSelected);
       
    }

};

 

usage:

pSettings->AddChildItem(new CPropertyGridItemColorList(_T("BackColor"), clr));

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Jay91 View Drop Down
Newbie
Newbie


Joined: 04 January 2006
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jay91 Quote  Post ReplyReply Direct Link To This Post Posted: 05 January 2006 at 5:19am

Thank you...oleg

but Your Source occurs compile error..

error C2039: 'OnDrawItemConstraint' : 'CXTPPropertyGridItemColor' is not member...

Why occur compile error ? my version is 9.81.....

I don't know why occur error....

Please Help me.....

 

 

Back to Top
Jay91 View Drop Down
Newbie
Newbie


Joined: 04 January 2006
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jay91 Quote  Post ReplyReply Direct Link To This Post Posted: 05 January 2006 at 6:13am

Thank you...oleg

I solve my problem for your help

It works Great...

 

 

 

 

 

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.328 seconds.