Solved

Setting a Background to CTreeCtrl

Posted on 1998-09-10
3
213 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now