Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. TreeCtrl

TreeCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structurestutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 423850
    wrote on last edited by
    #1

    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

    K 1 Reply Last reply
    0
    • U User 423850

      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

      K Offline
      K Offline
      KaRl
      wrote on last edited by
      #2

      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

      U 1 Reply Last reply
      0
      • K KaRl

        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

        U Offline
        U Offline
        User 423850
        wrote on last edited by
        #3

        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

        K 1 Reply Last reply
        0
        • U User 423850

          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

          K Offline
          K Offline
          KaRl
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups