各位大侠,发表下
6 个解决方案
#1
你的树控件class名字叫什么?!
#2
EXPENDED
#3
#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
#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.