• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 505
  • Last Modified:

Two lined CTreeCtrl item

I wish to display a tree control with each item having two lines of descriptive text.
I've tried using SetItemText with a newline character, but I just get a wierd char displyed:

SetItemText(HTREEITEM, "First line\nSecond line");

Does anyone know how I can have two lines of text on each item?
0
Gumpster
Asked:
Gumpster
1 Solution
 
Tommy HuiCommented:
The tree control does not automatically support multiple lines for the text. However, if you are using a newer version of the common controls: 4.71, then you can use a concept called custom draw. For more information about custom draw, search MSDN (www.microsoft.com/msdn) for custom draw.

Basically, when you insert an item into the tree control, you can specify how many default lines you want for the item. By default, this will be one. But, you can specify two to reserve two lines for use by a particular item.

But the control does not draw on the extra space. You have to do it yourself by using custom draw. Basically, you catch NM_CUSTOMDRAW and draw in the area yourself. So you would have to parse your strings and draw the text using DrawText() which allows you to draw on multiple lines by using DF_MULTILINE.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now