Print Page | Close Window

OnDrawItemConstraint Question

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=3466
Printed Date: 29 April 2024 at 2:51am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: OnDrawItemConstraint Question
Posted By: Jay91
Subject: OnDrawItemConstraint Question
Date 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...!!!




Replies:
Posted By: Oleg
Date 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


Posted By: Jay91
Date 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.....

 

 



Posted By: Jay91
Date Posted: 05 January 2006 at 6:13am

Thank you...oleg

I solve my problem for your help

It works Great...

 

 

 

 

 




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