Solved

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

Posted on 1997-06-19
6
2,503 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 100 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 190
notReplace  challenge 53 142
Capture logon name 13 87
Using Specialized Fonts in CSS 1 24
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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…

839 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