The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

TreeView and multiple images per item

Is it possible to put multiple images on an item in a TreeView control? Please take a look at the following picture to see what I mean:

As you can see here, there are 2 images on the children, a bar-like picture, and folder pictures.

Do I need to create my own widget to do this?
Wednesday, January 18, 2006
I'm pretty sure it can be done with the standard widget - but only if you understand pointers ;-)

Seriously... why do you need to use 2 images?

It looks like 2 images to the user, but what is to stop it being 1 image in your program?
S. Tanna
Wednesday, January 18, 2006
Don Send private email
Wednesday, January 18, 2006
Two approaches that spring to mind:

- write a new treeview (ugh lots of work)

- given that the existing treeview (talking only displays images by indexing (see, I get pointers!?!?!?) into an ImageList, and you need to make composite icons from the size bar and the regular file icon, you'd need to do a bit of jiggerypokery to add new composite icons as necessary to the imagelist. Derive from the Treeview, encapsulate away the gory details, and voila.
Larry Lard Send private email
Wednesday, January 18, 2006
We use Infragistics NetAdvantage, and the treeview in that allows multiple icons as far as i know.
Steve Haunts Send private email
Wednesday, January 18, 2006
I agree that it looks like it may be 1 image that is possibly a rendered bitmap at runtime.  At least it would be doable that way.
Ben Mc Send private email
Wednesday, January 18, 2006
What dev env?
IanH. Send private email
Wednesday, January 18, 2006
windows, visual studio c++
Wednesday, January 18, 2006
1. BitBlt your 2 images into 1

2. Then convert/add it to an image list.

3. Then pick the item from the image list, and assign it to the tree control line.

Skip step 1+2, and start off with an image list, containing all combinations of both images (per item in the imagelist), if there are only a fairly limited number of possible combinations.

Then add a method or message to your subclass of the tree control, that encapsulates the above.
S. Tanna
Wednesday, January 18, 2006
No, no, no. It is simply "owner draw". You get a rectangular area in OnDrawItem and you can draw as many icons onto your rectangle as you want (and using a CImageList makes it easy).
Anon and anon
Wednesday, January 18, 2006
Blitting multiple icons into the single icon space sounds like the most straightforward option. Thanks!
Wednesday, January 18, 2006
Define a second image list for the tree control:
treeCtrl.SetImageList(m_pStateList, TVSIL_STATE);

Use state images :
Hans-Georg Ulrich Send private email
Thursday, January 19, 2006
+1 for HGU

I was about to say this, but he got there first :-)

AFAIAC, the simplest ways are always the best. We use this method to show the status of files in the repository. For more than 2 images, though, you may need to use the owner-draw method.
Ewan McNab Send private email
Sunday, January 22, 2006

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz