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. |
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:
http://www.jam-software.com/freeware/freeware_treesize_gr.gif 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?
widget_boy 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?
Two approaches that spring to mind:
- write a new treeview (ugh lots of work) - given that the existing treeview (talking winforms.net) 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.
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.
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.
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!
widget_boy Wednesday, January 18, 2006 |
Powered by FogBugz