Solved

Setting a Background to CTreeCtrl

Posted on 1998-09-10
3
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.

756 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