From: Guillaume Legrand on
Hello,


I have a problem about images and CTreeCtrl. Actually I want to put
some images on the left (just before the text) of several items on the
tree, but not all. It is easy to put one image on each node and each
leaf of the tree. With CImageList::Create, CImageList::Add,
CTreeCtrl::SetImageList and CTreeCtrl::InsertItem, it works very well.
In order to have some items without any image to their left I put
negatives integer in the InsertItem function parameter (called
nImage), or integer beyond the list size. But actually we have a big
blank at the left of the text item in the tree, that is visually bad
and not acceptable. If we do not put TVIF_IMAGE flag, it forces image
to the first image of the list. So I just want to know how to have
images only on some items, not on all (if such thing is possible).


Sorry for my bad english and thanks beforehand.
Guillaume
From: Arny on
On 23.04.2010 15:51, Guillaume Legrand wrote:
> Hello,
>
>
> I have a problem about images and CTreeCtrl. Actually I want to put
> some images on the left (just before the text) of several items on the
> tree, but not all. It is easy to put one image on each node and each
> leaf of the tree. With CImageList::Create, CImageList::Add,
> CTreeCtrl::SetImageList and CTreeCtrl::InsertItem, it works very well.
> In order to have some items without any image to their left I put
> negatives integer in the InsertItem function parameter (called
> nImage), or integer beyond the list size. But actually we have a big
> blank at the left of the text item in the tree, that is visually bad
> and not acceptable. If we do not put TVIF_IMAGE flag, it forces image
> to the first image of the list. So I just want to know how to have
> images only on some items, not on all (if such thing is possible).
>
>
> Sorry for my bad english and thanks beforehand.
> Guillaume

Hi :)

The treeview control will reserve a rectangular area based on the size
of the images in the imagelist. This rectangle will be drawn even if the
index is invalid as you've noticed. This is the default behavior. AFAIK
there's no way to change this, unless you draw the images and text yourself.

- RaZ