Solved

Setting a Background to CTreeCtrl

Posted on 1998-09-10
3
230 Views
Last Modified: 2013-11-20
I want to change the background color of a tree control to black and the foreground to white.

I know there is a solution for that in codeGuru's site.
(http://www.codeguru.com/treeview/ctrl_color.shtml).
But, It seems that this solution dose'nt work well in Visual-C/5.0 or later. When I'm using it, the Tree's area filled with garbage when expanding/collapsing branches.

Any Idea, or a different solution for that problem?

0
Comment
Question by:motigust
  • 2
3 Comments
 
LVL 2

Expert Comment

by:prasanth
ID: 1322045
If you have VC++6 use CTreeCtrl::SetBkColor()
If you dont' have VC++6, send a TVM_SETBKCOLOR message to the control with the wParam=0 and lParam=COLORREF of the color you want. And use
#define TVM_SETBKCOLOR              (TV_FIRST + 29)

0
 
LVL 1

Author Comment

by:motigust
ID: 1322046
This is working the same as using GetCtlColor, The window background is painted with black, but the text/Icons/Lines appears with ugly white rectangled background.

0
 
LVL 2

Accepted Solution

by:
prasanth earned 200 total points
ID: 1322047
There is a TVM_SETTEXTCOLOR but it looks like you need something like SetTextBkColor (which the list view control has). Unfortunately that does not exist for the tree view control. You will need to do a owner drawn tree control. CodeGuru has some samples of owner drawn tree controls and VC comes with some too.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question