Can we add icons for specific tree items?
I am adding items with icon using following function:
HTREEITEM InsertItem(LPCTSTR lpszItem,int nImage,int nSelectedImage,HTREEITEM hParent = TVI_ROOT,HTREEITEM hInsertAfter = TVI_LAST);
To skip icon for an item, i am using -1 value for nImage
and nSelectedImage
. By doing this, icon is not appearing but space is coming.
Have you looked at CTreeCtrl::SetItem?
The easiest is to fill and pass a TVITEM structure.
You set the
mask
toTVIF_IMAGE
and specify theiImage
value.To begin, you need to create a
CImageList
object that stays valid for the duration of theCTreeCtrl
. You usually add it to the class as a variable. Example:Once it is initialised you can call CTreeCtrl::SetImageList. Example:
Thereafter you can use the image index values.