Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CTreeCtrl: How to change color & font of text items?

Posted on 1997-06-19
6
Medium Priority
?
2,641 Views
Last Modified: 2013-12-03
I would like to change the color and/or font of individual text items in a Tree Control. For example, I would like to use red and/or blue along with a specific font to indicate a state for a given node(s) in the tree control. I will be using several combinations of colors and fonts in the     tree control.

I do not have much knowledge about tree controls. I basically created a tree control class derived from CTreeCtrl.

I appreciate any help you can provide.

Thanks.

0
Comment
Question by:k2041097
[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
6 Comments
 

Author Comment

by:k2041097
ID: 1302191
I am using Windows 95 with Visual C++ version 4.2.  The COMCTL32.DLL is version 4.70
0
 
LVL 3

Expert Comment

by:byang
ID: 1302192
Just owner-draw it.
0
 

Expert Comment

by:PostMan
ID: 1302193
I have posted a similar question. But here are some things to know....
CTreeCtrl is derived from CWnd which has a method called .SetFont() which is what you would want to use to change the font .  Trouble is, I don't know if CTreeCtrl supports the .SetFont() method. I don't have any documentation on this. If it does you will want to instantiate a CFont obj then call .Create() passing whatever params you want for your font. Then you will want to call .SetFont() on the CTreeCtrl obj

Hope this helps, and please let me know if it works.

-PostMan

0
Technology Partners: 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!

 
LVL 4

Expert Comment

by:AVaulin
ID: 1302194
The easiest way to do what you want is using different images in tree control. SetItemImage method allow you to change current image for item. See SAMPLES\MFC\GENERAL\CMNCTRLS example how to create tree control with images. Try and good luck.
0
 

Author Comment

by:k2041097
ID: 1302195
I cannot use images to specify states since I will be using them to indicate 'types' within the tree structure.  I need to be able to change both fonts and colors of text items in the tree.  
Microsoft Tech Support answered by saying that there's no way of doing this with the common controls in version 4.2.  However, they referred me to articles in the '96 October and November issues of MSJ.  These articles feature the new internet explore common controls.  The solution is to use NM_CUSTOMDRAW w/ CDDS_PREPAINT.
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 300 total points
ID: 1302196
Please be careful when using those control features: the version of COMCTL32.DLL that supports them is not yet redistributable. If you make your application dependant on those new features, you'll need to make sure that your users install IE 3.0 on their machine.

When IE 4 ships, you'll be able to update the DLL yourself.  At this time, you should expect to need to alter your program, as the programatic interface of the DLL will change.

Until then, you should read the CC_INFO.DOC file that's in the SDK to get the details of the license that applies to the beta version of COMCTL32.DLL that you're using.

.B ekiM

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 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