Print Page | Close Window

CXTTreeCtrl Background and text colors

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


Topic: CXTTreeCtrl Background and text colors
Posted By: aamirzia
Subject: CXTTreeCtrl Background and text colors
Date Posted: 07 January 2007 at 4:16am
Hi All,
 
I am using CXTTreeCtrl and i want to change the background color of the whole tree ctrl(not only the selected items) and also the text color(when tree item is selected or unselected both cases).
 
Please help me out, i was unable to find any such api in CXTTreeCtrl class.
 
Thanx
 
Aamir



Replies:
Posted By: danpetitt
Date Posted: 07 January 2007 at 10:52am
There are some overrides you can use to specify a text colour ... GetTextColor I think which passes in an HTREEITEM so you can decide what it should be.
 
As for tree background colour, I think there is one for that as well.


Posted By: kstowell
Date Posted: 07 January 2007 at 1:04pm
Hello,
 
You can use the following base class members to set and get text and background colors for the tree control:

COLORREF CTreeCtrl::SetBkColor( COLORREF clr );
COLORREF CTreeCtrl::GetBkColor( ) const;
COLORREF CTreeCtrl::SetTextColor( COLORREF clr );
COLORREF CTreeCtrl::GetTextColor( ) const;

Example:
// change text color to white and background to dark blue
pTree->SetTextColor(RGB(255, 255, 255));
ASSERT(pTree->GetTextColor() == RGB(255, 255, 255));
pTree->SetBkColor(RGB(0, 0, 128));
ASSERT(pTree->GetBkColor() == RGB(0, 0, 255));
// force repaint immediately
pTree->Invalidate();
 
Hope this helps.
 
Codejock Support



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