Print Page | Close Window

CXTPPropertyGrid: Custom Colors for Captions

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=9719
Printed Date: 14 November 2025 at 7:21pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPPropertyGrid: Custom Colors for Captions
Posted By: MacW
Subject: CXTPPropertyGrid: Custom Colors for Captions
Date Posted: 27 February 2008 at 9:32am
Hi,

it seems that it is not possible to color individual captions of a CXTPPropertyGrid. I need different colors for different captions.

Using my own CXTPPropertyGridPaintManager and overriding the GetItemTextColor and GetItemBackColor works only for normal items, but not captions.

The problem is the call to DrawCategoryCaptionBackground in "TPPropertyGridPaintManager.cpp" which fills the entire caption with the line color.

This method is not virtual and hence I cannot change the behavior.

Can this be made virtual in the next ToolkitPro release?

And while you're at it, would it be possible to change the AddCategory  / InsertCategory of CXTPPropertyGrid in a way that allows us to use objects derived from CXTPPropertyGridItem?

This is currently only possible with AddChildItem, but not for categories. This causes some rather rough work-arounds. It would be much simpler if you would add a method like

virtual CXTPPropertyGridItem* CreateInstance() which just does a

return new CXTPPropertyGridItem

in the CXTPPropertyGrid class, but could be overloaded to return a derived class instead in a class derived from CXTPPropertyGridItem.










Replies:
Posted By: Oleg
Date Posted: 27 February 2008 at 11:01am
Hi,
DrawCategoryCaptionBackground is virtual even in 11.1.3 version.
 
Good suggestion about InsertCategory. Changed.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: MacW
Date Posted: 27 February 2008 at 2:33pm
Hi, Oleg

Thanks. Must have looked at a derived PaintManager accidentally

The problem I have is that I don't know _which_ caption is to be drawn inside this method. I would need to override the entire DrawItem method in order to change how the caption is filled. The GetItemBackColor takes the item as a parameter, but not the DrawCategoryCaptionBackground method...

Two virtual methods like GetCaptionBackColor and GetCaptionTextColor would solve this problem for me. And would bring the caption painting mechanism in line with the painting mechanism of the normal items.


Thanks for allowing us to use derived classes as categories in upcoming versions. This makes it easier to associate custom data with categories, like with items now.

PS.: I hope XAML support will also make it to the property grid



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