Menu

How do I change text color in a tree view?

2003-02-07
2012-09-26
  • Nobody/Anonymous

    To change the text color in a tree view you can do something like this:

    SendMessage(hTreeView, TVM_SETTEXTCOLOR, 0, (LPARAM) (COLORREF)RGB(0,0,255));

    But that affects all of the text. I want to change it per item. I know it is possible, but how??

    -Jay

     
    • Nobody/Anonymous

      I'll be damned. This happens all the time. I ask a question and nobody has the answer.

      -Jay

       
    • Nobody/Anonymous

      The fact is, most have jobs and something else to do other then be here for questions.

       
    • Nobody/Anonymous

       
    • Nobody/Anonymous

      No, no, no.. we are all here for questions. Some to ask them , some to answer them. Or both. But don't get me wrong: I'm not complaining. On the contrary, I'm very grateful for the support I get here.

      As for the second answer: I have not been able to get any WM_CTLCOLOR** to work for the treeview.

      -Jay

       
    • Nobody/Anonymous

      Maybe this is all crap, cause i have never colored a Tree View Control, but i know the existence of this macros:
      TreeView_GetBkColor
      TreeView_GetInsertMarkColor
      TreeView_GetLineColor
      TreeView_GetTextColor
      TreeView_SetBkColor
      TreeView_SetInsertMarkColor
      TreeView_SetLineColor
      TreeView_SetTextColor

      There probably are more macros or messages you could use. I could find those doing a quick search on MSDN.

      You probably knew all of them, anyway if you dont, youll find some Tree View info and examples here:
      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/reflist.asp

      At the end of the page at the link above, theres a list of the Messages a Tree View Control processes, so you have to decide how to deal with each of them in order to set the appearance of your Tree View control.
      I didnt look at it, but probably WM_PAINT or WM_DRAWITEM or something like that is there.

      And sorry if you knew all that and this help was useless :) I know absolutely nothing about tree view controls.

      Good luck,
      /Effenberg

       
    • Nobody/Anonymous

      Thanks Effenberg! There even was some example code on how to do it. It's not easy (and MFC) but I'll figure it out.

      -Jay

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.