This is an example how to enable colors in Tree Controls.
Actually I saw a similar Article from a friend,
but it was based on
CTreeView, not on
CTreeCtrl which I actually needed.
Below are some of the many features that
- Change the item color.
- Change the item font.
- Make the item bold.
- Get the item color.
- Get the item font.
- Get if item is bold.
- And more in future.
It is so easy, you only need to include the class
in your project, and create control member variable from that class.
The function name and the parameters you can find in the source zip file. Here
is some sample code from the demo app. Here
m_cTree is a member of type
HTREEITEM hOrder, hContent;
for(int i = 0; i < 255; i++)
hOrder[i] = m_cTree.InsertItem(sStr);
for (int j = 0; j < 5; j++)
hContent[j] = m_cTree.InsertItem(sStr, hOrder[i]);
m_cTree.SetItemColor(hContent[j], RGB(i, 255, 0));
m_cTree.SetItemColor(hOrder[i], RGB(255, i, 0));
Setting color and font attribute for individual items
CTreeCtrlEx is inspired by code, ideas, and submissions from the following:
- By Zafir Anjum