简体   繁体   中英

C++ MFC - CTreeCtrl - Difference between SelectItem and SetItemState

I need to create a Tree List for my windows application, with multiple selection of nodes with drag-and-drop support. Since Microsoft doesn't provide any such property for the tree which eases the work of the developer, I have to implement this features on my own.

Can somebody explain me the differences (also, the corresponding getters for the following statements) and when to use

SetItemState(hItem, 1, TVIS_SELECTED);

and

SelectItem(hItem);

and

SetItemState(hItem, TVIS_SELECTED, TVIS_SELECTED);

The primary difference is that SelectItem is functionally built off of SetItemState . Along with anything else it does, SelectItem will use SetItemState (or equivalent internal calls) to set TVIS_SELECTED for the new item, and, say, remove it from the previously selected item.

In order to implement your own multiple-selection control, you have to prevent SelectItem from being called when you want to augment the selection instead of replacing it. There are a lot of cases to consider, ranging from mouse clicks with various modifier keys held to keyboard navigation, so good luck in your implementation!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM