各位大侠,发表下
6 个解决方案
#1
你的树控件class名字叫什么?!
#2
EXPENDED
#3
![MFC中如何判断树控件某个根节点前是展开的还是收缩的? MFC中如何判断树控件某个根节点前是展开的还是收缩的?](https://image.shishitao.com:8440/aHR0cHM6Ly93d3cuaXRkYWFuLmNvbS9nby9hSFIwY0hNNkx5OW1iM0oxYlM1amMyUnVMbTVsZEM5UWIybHVkRVp2Y25WdEwzVnBMM05qY21sd2RITXZZM05rYmk5UWJIVm5hVzR2TURBeEwyWmhZMlV2T0RVdVoybG0%3D.jpg?w=700)
#4
GetItemState获取节点的状态再判断下TVIS_EXPANDED标志
#5
// get child "N:'
HTREEITEM hN_drive=LeftTree.GetChildItem(hTreeRoot);
// check if n: expended once ?
UINT ret=LeftTree.GetItemState(hN_drive,TVIS_EXPANDEDONCE);
if(ret & TVIS_EXPANDEDONCE)
{ // insert "spf.dir"
TreeCtrlItem.hParent =hN_drive;
TreeCtrlItem.item.pszText =N_SubTree[4];// "SPF.DIR"
TreeCtrlItem.hInsertAfter=TVI_LAST;
HTREEITEM hTreeItemSpf = LeftTree.InsertItem(&TreeCtrlItem);
// set image
LeftTree.SetItemImage(hTreeItemSpf,iDIR,iEXPND);
}
HTREEITEM hN_drive=LeftTree.GetChildItem(hTreeRoot);
// check if n: expended once ?
UINT ret=LeftTree.GetItemState(hN_drive,TVIS_EXPANDEDONCE);
if(ret & TVIS_EXPANDEDONCE)
{ // insert "spf.dir"
TreeCtrlItem.hParent =hN_drive;
TreeCtrlItem.item.pszText =N_SubTree[4];// "SPF.DIR"
TreeCtrlItem.hInsertAfter=TVI_LAST;
HTREEITEM hTreeItemSpf = LeftTree.InsertItem(&TreeCtrlItem);
// set image
LeftTree.SetItemImage(hTreeItemSpf,iDIR,iEXPND);
}
#6
TVIS_EXPANDED The item's list of child items is currently expanded; that is, the child items are visible. This value applies only to parent items.
TVIS_EXPANDEDONCE The item's list of child items has been expanded at least once. The TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification messages are not generated for parent items that have this state set in response to a TVM_EXPAND message. Using TVE_COLLAPSE and TVE_COLLAPSERESET with TVM_EXPAND will cause this state to be reset. This value applies only to parent items.
TVIS_EXPANDEDONCE The item's list of child items has been expanded at least once. The TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification messages are not generated for parent items that have this state set in response to a TVM_EXPAND message. Using TVE_COLLAPSE and TVE_COLLAPSERESET with TVM_EXPAND will cause this state to be reset. This value applies only to parent items.
#1
你的树控件class名字叫什么?!
#2
EXPENDED
#3
![MFC中如何判断树控件某个根节点前是展开的还是收缩的? MFC中如何判断树控件某个根节点前是展开的还是收缩的?](https://image.shishitao.com:8440/aHR0cHM6Ly93d3cuaXRkYWFuLmNvbS9nby9hSFIwY0hNNkx5OW1iM0oxYlM1amMyUnVMbTVsZEM5UWIybHVkRVp2Y25WdEwzVnBMM05qY21sd2RITXZZM05rYmk5UWJIVm5hVzR2TURBeEwyWmhZMlV2T0RVdVoybG0%3D.jpg?w=700)
#4
GetItemState获取节点的状态再判断下TVIS_EXPANDED标志
#5
// get child "N:'
HTREEITEM hN_drive=LeftTree.GetChildItem(hTreeRoot);
// check if n: expended once ?
UINT ret=LeftTree.GetItemState(hN_drive,TVIS_EXPANDEDONCE);
if(ret & TVIS_EXPANDEDONCE)
{ // insert "spf.dir"
TreeCtrlItem.hParent =hN_drive;
TreeCtrlItem.item.pszText =N_SubTree[4];// "SPF.DIR"
TreeCtrlItem.hInsertAfter=TVI_LAST;
HTREEITEM hTreeItemSpf = LeftTree.InsertItem(&TreeCtrlItem);
// set image
LeftTree.SetItemImage(hTreeItemSpf,iDIR,iEXPND);
}
HTREEITEM hN_drive=LeftTree.GetChildItem(hTreeRoot);
// check if n: expended once ?
UINT ret=LeftTree.GetItemState(hN_drive,TVIS_EXPANDEDONCE);
if(ret & TVIS_EXPANDEDONCE)
{ // insert "spf.dir"
TreeCtrlItem.hParent =hN_drive;
TreeCtrlItem.item.pszText =N_SubTree[4];// "SPF.DIR"
TreeCtrlItem.hInsertAfter=TVI_LAST;
HTREEITEM hTreeItemSpf = LeftTree.InsertItem(&TreeCtrlItem);
// set image
LeftTree.SetItemImage(hTreeItemSpf,iDIR,iEXPND);
}
#6
TVIS_EXPANDED The item's list of child items is currently expanded; that is, the child items are visible. This value applies only to parent items.
TVIS_EXPANDEDONCE The item's list of child items has been expanded at least once. The TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification messages are not generated for parent items that have this state set in response to a TVM_EXPAND message. Using TVE_COLLAPSE and TVE_COLLAPSERESET with TVM_EXPAND will cause this state to be reset. This value applies only to parent items.
TVIS_EXPANDEDONCE The item's list of child items has been expanded at least once. The TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification messages are not generated for parent items that have this state set in response to a TVM_EXPAND message. Using TVE_COLLAPSE and TVE_COLLAPSERESET with TVM_EXPAND will cause this state to be reset. This value applies only to parent items.