我做的是树控件的多选功能,在多选过程中,需要给新点击的项设置focus,只有下面这种情况,能保留多选的高亮
CTreeCtrl::SelectItem(hItem);
CTreeCtrl::SetItemState(hFocus, TVIS_SELECTED, TVIS_SELECTED);
CTreeCtrl::SelectItem(hItem);
其中hFocus是当前选中的item,hItem是要选中的item
这种情况实现的多选,在按住Ctrl取消之前的选择时,会消除之前这一项和他上一次选中项的高亮!目前的问题就是这个,求高人指点啊。
多选我参考的方案原代码是
CTreeCtrl::SelectItem(NULL); //will cause notify, but can be taken as focus change
CTreeCtrl::SetItemState(hFocus, TVIS_SELECTED, TVIS_SELECTED);
CTreeCtrl::SelectItem(hItem); //set focus (will consequently select, if not already focused)
这种在他的原解决方案里能实现多选效果,而且没问题,但是拿出来我用,就实现不了,他是用单文档实现的,我需要在mfc窗口中实现!