TreeCtrl
-
Hi friends, i am doing an mfc application i am having a tree ctrl. Now the thing is i dont want the tree ctrl to collapse how to do it any suggestion is welcome. Thanx TAKE CARE
-
Hi friends, i am doing an mfc application i am having a tree ctrl. Now the thing is i dont want the tree ctrl to collapse how to do it any suggestion is welcome. Thanx TAKE CARE
Try this:
void CMyTreeCtrl::CollapseBranch(HTREEITEM hti) { if(ItemHasChildren(hti)){ Expand(hti, TVE_COLLAPSE); hti = GetChildItem(hti); do CollapseBranch(hti); while((hti = GetNextSiblingItem(hti)) != NULL); } } void CMyTreeCtrl::CollapseAll() { HTREEITEM hti = GetRootItem(); do{ CollapseBranch(hti); }while((hti = GetNextSiblingItem(hti)) != NULL); }
HTH, K.
Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed - Dwight D. Eisenhower
-
Try this:
void CMyTreeCtrl::CollapseBranch(HTREEITEM hti) { if(ItemHasChildren(hti)){ Expand(hti, TVE_COLLAPSE); hti = GetChildItem(hti); do CollapseBranch(hti); while((hti = GetNextSiblingItem(hti)) != NULL); } } void CMyTreeCtrl::CollapseAll() { HTREEITEM hti = GetRootItem(); do{ CollapseBranch(hti); }while((hti = GetNextSiblingItem(hti)) != NULL); }
HTH, K.
Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed - Dwight D. Eisenhower
hi friend, Hey this code is not working in following senario.. what i have done is i have mapped TVN_ITEMEXPANDING of the Tree ctrl in my Dialog box Class. then i have assigned a variable to the treectrl named m_treectrl i have written the code u have provided in the Dialog box class and have inserted the m_treectrl var before the CTreectrl Class function u have used in the collapse function for eg GetRootItem(); has been replaed by m_TreeCtrl.GetRootItem(); and in the TVN_ITEMEXPANDING I have called the collapseall function but it doesnt work. can u suggest any help ?? waiting for ur reply... Thanx TAKE CARE
-
hi friend, Hey this code is not working in following senario.. what i have done is i have mapped TVN_ITEMEXPANDING of the Tree ctrl in my Dialog box Class. then i have assigned a variable to the treectrl named m_treectrl i have written the code u have provided in the Dialog box class and have inserted the m_treectrl var before the CTreectrl Class function u have used in the collapse function for eg GetRootItem(); has been replaed by m_TreeCtrl.GetRootItem(); and in the TVN_ITEMEXPANDING I have called the collapseall function but it doesnt work. can u suggest any help ?? waiting for ur reply... Thanx TAKE CARE
sorry, I wasn't careful enough when reading, I understood you wanted to collapse your treectrl :-O To avoid it to collapse, do this:
void CTreeDialog::OnItemexpandingTreectrl(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; *pResult = (pNMTreeView->action == TVE_COLLAPSE); }
Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed - Dwight D. Eisenhower