Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 1997-06-19
6
Medium Priority
?
2,694 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
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
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.
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…

885 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