Hello,
I'm trying to modify a tree view item's image dependant on whether it is expanded or not. The two images in the associated image list are side-by-side (Indexes 0 and 1), so it shouldn't be difficult to do it. Here's how I've tried to do it:-
However, while the item's data does appear to be indeed modified through that process, the actual image does not change. I've tried setting the initial image to 1; The second image is displayed initially, and once the item is expanded it changes back to image 0, but it doesn't go the other way (If I collapse it again the image does not change). Something which changes does not seem to be acted upon properly, and it's really annoying.Code:(hwndTreeView = global tree view window handle) (In my main window's WindowProc) case WM_NOTIFY: { switch ((LPNMHDR(lParam))->code) { case TVN_ITEMEXPANDED: { LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam; TVITEM tvi; tvi.hItem = pnmtv->itemNew.hItem; tvi.mask = TVIF_IMAGE; SendMessage(hwndTreeView, TVM_GETITEM, 0, (LPARAM)&tvi); if (pnmtv->itemNew.state & TVIS_EXPANDED) tvi.iImage++; //go from 0 to 1 else tvi.iImage--; //go from 1 to 0 SendMessage(hwndTreeView, TVM_SETITEM, 0, (LPARAM)&tvi); break; } } break; }
I'll open the floor to Q&A now![]()



LinkBack URL
About LinkBacks



