Reputation: 751
I have a TreeView control in a Windows C++ application that has an ImageList set.
I am trying to insert an node that does not have icon (without TVIF_IMAGE
flag) but the icon is still displayed.
TVINSERTSTRUCT tvis = { 0 };
tvis.hParent = hParent;
tvis.hInsertAfter = hInsertAfter;
tvis.item.mask = TVIF_TEXT;
tvis.item.pszText = (LPTSTR) lpszItem;
tvis.item.iImage = 0;
tvis.item.iSelectedImage = 0;
tvis.item.state = nState;
tvis.item.stateMask = nStateMask;
tvis.item.lParam = lParam;
::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis);
Is that possible/ supported ?
Upvotes: 3
Views: 1601
Reputation: 69706
The thing is you are inserting an item with [default] image 0. You not only need -1
, but you also need TVIF_IMAGE
:
tvis.item.mask = TVIF_TEXT | TVIF_IMAGE;
tvis.item.iImage = -1;
Here is the effect of this change compared you your snippet (source code):
Upvotes: 3