Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CTreeView & CImageList 1

Status
Not open for further replies.

BM

Programmer
Apr 26, 2000
27
GB
Hi,
I am using CTreeView to list some files and would like the root to have a different image to the rest of the Items. Also I would like the images to change on selection. How do I arrange the CImageList to do this and how do I access bitmaps in it from the insert statement, how do I change the bitmap dynamically.
Is there a standard image list containing the bitmaps in Explorer or similar?

Thanks

Barry M.
 
Create the image list with CImageList::Create() function, add a bunch of images to a image list with the CImageList::Add() function (it is also possible to have one bitmap with all your images and have the image list scan for individual images based on width but that is more complicated), get the CTreeCtrl object from the CTreeView object your using and call CTreeCtrl::SetImageList(), now on each call to CTreeCtrl::InsertItem() use the appropriate image index for the nImage paramater and the appropriate selected image index for the nSelectedImage parameter. Use the necessary logic to change the images based on the items your inserting for your particular application. You can also change an items image at anytime by calling CTreeCtrl::SetItemImage().

bitwise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top