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

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.

k2041097Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

k2041097Author Commented:
I am using Windows 95 with Visual C++ version 4.2.  The COMCTL32.DLL is version 4.70
0
byangCommented:
Just owner-draw it.
0
PostManCommented:
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

AVaulinCommented:
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
k2041097Author Commented:
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
mikeblasCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.