Hi, I have generated an Explorer-style application in VC++ 6 and I've been working with the CTreeView in the left-side pane.
I am populating the underlying CTreeCtrl using something like:
CString desc = GetItemDescriptionFromElsewhere();
treeItem.hParent = 0;
treeItem.hInsertAfter = TVI_SORT;
hCurr = ctlTree.InsertItem(&treeItem);
ctlTree.SetItemState( hCurr, 0, TVIS_SELECTED );
ctlTree.SetItemImage( hCurr, 0, 1 ); // ImageList defined elsewhere
Am I doing this correctly? Am I missing something?
1) When the TreeView first renders, EVERYTHING appears selected (the text is highlighted although the focus box doesn't appear to be present). When I individually click on the various items, previous ones DO get de-selected (un-highlighted). This sounds like I have to individually refresh each and every item in the tree to reflect its non-selected status (I issue a GetTreeCtrl().SelectItem(NULL)) in OnInitDialog().
Is there a heuristic for doing this? None of the examples I've looked at do anything special - it just seems to behave as I want by default, although granted, they're all using (or subclassing) CTreeCtrl's directly within a dialog.
2) Is there a standard approach for explicitly setting the bitmap to display based on whether the item is expanded or not? Do I have to intercept all of the TVM_ITEMEXPANDING and TVM_ITEMEXPANDED events?
Thanks for your help.