Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Property Grid
  New Posts New Posts RSS Feed - CXTPPropertyGridItem colors
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPPropertyGridItem colors

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


Joined: 16 July 2004
Status: Offline
Points: 60
Post Options Post Options   Thanks (0) Thanks(0)   Quote hpesata Quote  Post ReplyReply Direct Link To This Post Topic: CXTPPropertyGridItem colors
    Posted: 12 May 2005 at 5:55am
Hi!

XTP 9601

I need to set different for/background-colors for different property-grid-items.
CXTPPropertyGrid::SetCustomColors() just enables me to change the color for ALL items.

A similar function like CXTListBase::SetRowColor() would be what I need,
something like pItem->SetColor(clrFore, clrBack).

are there any plans on including this functionality in future versions ?
I saw several requestes on this topic in the forum.

thanx in advance!

regards,
Hans

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: 12 May 2005 at 3:44pm

Yes, we have this in our TODO list for 10.0 release.

Thank  you.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Kevin6 View Drop Down
Groupie
Groupie


Joined: 13 May 2005
Location: United Kingdom
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote Kevin6 Quote  Post ReplyReply Direct Link To This Post Posted: 13 May 2005 at 7:37am

I also have this problem. Is there a work around for now that you can suggest?

(Also when is the planned release date for 10.0?)

Regards,

Kevin.

 

Kevin.
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: 13 May 2005 at 8:12am

You can:

1. Create custom item inherited from CXTPPropertyGridItem

2. Override OnDrawItemValue

 

or

 

1 Create custom pain manager inherited from CXTPPropertyGridPaintManager

2. Override void DrawItem(PDRAWITEMSTRUCT lpDrawItemStruct)

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Kevin6 View Drop Down
Groupie
Groupie


Joined: 13 May 2005
Location: United Kingdom
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote Kevin6 Quote  Post ReplyReply Direct Link To This Post Posted: 13 May 2005 at 8:16am

Thanks Oleg, but you avoided my other question!

I have quite a large application to write and could leave the colouring for now and come back to it later. But I would need to know if 10.0 was 3, 6, 12+ months away. Just a general idea would do.

Regards,

Kevin.

 

 

 

Kevin.
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: 13 May 2005 at 3:18pm
In Summer :)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Kevin6 View Drop Down
Groupie
Groupie


Joined: 13 May 2005
Location: United Kingdom
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote Kevin6 Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2005 at 10:19am

Thanks, that good enough for me!

Regards,

Kevin.

 

Kevin.
Back to Top
CGrant View Drop Down
Newbie
Newbie
Avatar

Joined: 30 May 2005
Location: United Kingdom
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote CGrant Quote  Post ReplyReply Direct Link To This Post Posted: 30 May 2005 at 8:59am
Originally posted by oleg oleg wrote:

You can:

1. Create custom item inherited from CXTPPropertyGridItem

2. Override OnDrawItemValue

I'd also like to see a sinple way to set the background color, but the suggestion worked for me. In my case I wanted a simple valid / invalid coloring of items (numeric items outside a min to max range)

I always find code examples handy; so I have a class dervied from the ...GridItemNumber that adds range checking by looking at the ::SetValue string to set bool m_valid. The draw override uses it like this:

BOOL RangeCheckedGridItemNumber::OnDrawItemValue(CDC& dc, CRect rcValue)
{
 if (!m_valid)
 {
  // Highlight in red for invalid items
  CBrush red(RGB(255,128,128));
  dc.FillRect(rcValue, &red);
 }

 return CXTPPropertyGridItemNumber::OnDrawItemValue(dc, rcValue);
}

Keep up the good work

Colin



Edited by CGrant
Back to Top
hpesata View Drop Down
Groupie
Groupie


Joined: 16 July 2004
Status: Offline
Points: 60
Post Options Post Options   Thanks (0) Thanks(0)   Quote hpesata Quote  Post ReplyReply Direct Link To This Post Posted: 31 May 2005 at 3:16am
Hi Colin!

thanx for your hint!

I am lookong for a way to also color the item-caption, not only the value.
Do You have any idea on how to do that ?

thanx in advance!

regards,
Hans

Back to Top
CGrant View Drop Down
Newbie
Newbie
Avatar

Joined: 30 May 2005
Location: United Kingdom
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote CGrant Quote  Post ReplyReply Direct Link To This Post Posted: 01 June 2005 at 8:02pm

Originally posted by hpesata hpesata wrote:


I am looking for a way to also color the item-caption, not only the value.
Do You have any idea on how to do that ?

I had hoped it would be easy but I haven't exactly managed it. The closest I could get involved my own class derived from CXTPPropertyGridPaintManager


class CColorItemPaintManager : public CXTPPropertyGridPaintManager
{
public:
    CColorItemPaintManager(CXTPPropertyGrid* pGrid);
    virtual ~CColorItemPaintManager();
    virtual void DrawItem(PDRAWITEMSTRUCT lpDrawItemStruct);
};

which I set in to the property grid when I created it


if ( m_wndPropertyGrid.Create( rc, this, IDC_PROPERTY_GRID ) )
{
    m_pPaintManager = new CColorItemPaintManager(&m_wndPropertyGrid);
    m_wndPropertyGrid.SetCustomTheme(m_pPaintManager);

and then, as an example, override DrawItem to splat red down on the selected row.


void CColorItemPaintManager::DrawItem(PDRAWITEMSTRUCT lpDrawItemStruct)
{
    if (ODS_SELECTED == (ODS_SELECTED & lpDrawItemStruct->itemState))
    {
        CRect rc = lpDrawItemStruct->rcItem;
        CDC dc;
        dc.Attach(lpDrawItemStruct->hDC);
        dc.FillSolidRect(rc, RGB(255,0,0));
        dc.Detach();
    }
    else
    {
        CXTPPropertyGridPaintManager::DrawItem(lpDrawItemStruct);
    }
}

The grid item value is still getting painted nicely but the caption is just a solid red rectangle. Filling it in nicely needs a fair bit more work - see Samples\PropertyGrid\OwnerDraw\SimpleGridPage.cpp for its DrawItem code.

Good luck!

Colin

 

Back to Top
hpesata View Drop Down
Groupie
Groupie


Joined: 16 July 2004
Status: Offline
Points: 60
Post Options Post Options   Thanks (0) Thanks(0)   Quote hpesata Quote  Post ReplyReply Direct Link To This Post Posted: 02 June 2005 at 3:30am
Hi Colin!

Thanx a lot for your detailled support!

regards,
Hans

Back to Top
CGrant View Drop Down
Newbie
Newbie
Avatar

Joined: 30 May 2005
Location: United Kingdom
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote CGrant Quote  Post ReplyReply Direct Link To This Post Posted: 07 June 2005 at 7:48pm

Now that I've coughed up the price of the MFC version of PropertyGrid I've got the sources , so I've revisited it to see if it would be easy enough to change the base class to get grid items coloured.

I fell foul of include ordering so I opted for this slightly odd approach: I added a virtual method to the class CXTPPropertyGridItem to get the background colour for that item.


virtual void GetBackgroundColour(COLORREF & clr) { }

and changed the CXTPPropertyGridPaintManager::DrawItem to use that colour


    COLORREF clrWindow = pView->m_clrBack;   <-- existing line
    pItem->GetBackgroundColour(clrWindow);    <--- added line

That meant that nothing changed until I had my own class RangeCheckedGridItemNumber derived CXTPPropertyGridItemNumber from that overrode the  mehtod


void RangeCheckedGridItemNumber::GetBackgroundColour(COLORREF & clr)
{
    clr = RGB(0,255,0);  // very green
}

Obviously you can have any logic you like in your method. I quite like the solution since it is a minimal change, but it does change the library; I hope the next release will have its own SetBackgroundColor() method instead

Colin

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