简体   繁体   English

C ++ MFC-CTreeCtrl-SelectItem和SetItemState之间的区别

[英]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. 我需要为Windows应用程序创建一个树列表,并通过拖放支持选择多个节点。 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. 由于Microsoft没有为树提供任何此类属性以减轻开发人员的工作负担,因此我必须自己实现此功能。

Can somebody explain me the differences (also, the corresponding getters for the following statements) and when to use 有人可以解释一下它们的区别(以及以下语句的相应getter)以及何时使用

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 . 主要区别在于SelectItem在功能上是基于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. 与其他操作一起, SelectItem将使用SetItemState (或等效的内部调用)为新项目设置TVIS_SELECTED ,例如,将其从先前选择的项目中删除。

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. 为了实现自己的多重选择控件,当您要扩大选择范围而不是替换选择范围时,必须防止调用SelectItem 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! 有很多情况需要考虑,从按住各种修饰键的鼠标单击到键盘导航,不一而足!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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