Solved

Setting a Background to CTreeCtrl

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

729 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