Solved

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

Posted on 1997-06-19
6
2,464 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
Comment Utility
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
Comment Utility
Just owner-draw it.
0
 

Expert Comment

by:PostMan
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 4

Expert Comment

by:AVaulin
Comment Utility
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
Comment Utility
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 100 total points
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
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…

763 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

7 Experts available now in Live!

Get 1:1 Help Now