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. Strange CTreeCtrl behavior

Strange CTreeCtrl behavior

Scheduled Pinned Locked Moved C / C++ / MFC
7 Posts 3 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.
  • K Offline
    K Offline
    Ken Goguen
    wrote on last edited by
    #1

    I have a strange one. I have my own CTreeCtrl for doing multi-select. When build/run a debug version it works just fine. When I build/run a release version, my tree nodes get populated, but I do not see any + on the parent nodes and cannot expand them to see the children. But I can do all that in the debug version without a problem. Any Ideas? :eek: -kg // *** TreeView CMulSelTreeCtrl* pMyTree = (CMulSelTreeCtrl*) GetDlgItem(IDC_TREE1); ASSERT(pMyTree != NULL); pMyTree ->DeleteAllItems(); pMyTree ->ModifyStyle(NULL, TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS); // Associate the image list with the tree control. pMyTree ->SetImageList(pilMyTree, TVSIL_NORMAL); TVINSERTSTRUCT tvInsert; tvInsert.hParent = NULL; tvInsert.hInsertAfter = NULL; tvInsert.item.mask = TVIF_TEXT | TVIF_CHILDREN; // *** TreeView tvInsert.item.pszText = _T(buffer); HTREEITEM hTreeItem = pMyTree ->InsertItem(&tvInsert); Ken Goguen Principle Design Engineer EMC Corporation

    M T 2 Replies Last reply
    0
    • K Ken Goguen

      I have a strange one. I have my own CTreeCtrl for doing multi-select. When build/run a debug version it works just fine. When I build/run a release version, my tree nodes get populated, but I do not see any + on the parent nodes and cannot expand them to see the children. But I can do all that in the debug version without a problem. Any Ideas? :eek: -kg // *** TreeView CMulSelTreeCtrl* pMyTree = (CMulSelTreeCtrl*) GetDlgItem(IDC_TREE1); ASSERT(pMyTree != NULL); pMyTree ->DeleteAllItems(); pMyTree ->ModifyStyle(NULL, TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS); // Associate the image list with the tree control. pMyTree ->SetImageList(pilMyTree, TVSIL_NORMAL); TVINSERTSTRUCT tvInsert; tvInsert.hParent = NULL; tvInsert.hInsertAfter = NULL; tvInsert.item.mask = TVIF_TEXT | TVIF_CHILDREN; // *** TreeView tvInsert.item.pszText = _T(buffer); HTREEITEM hTreeItem = pMyTree ->InsertItem(&tvInsert); Ken Goguen Principle Design Engineer EMC Corporation

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      Init your structs to zero before using them: TVINSERTSTRUCT tvInsert = {0}; --Mike-- http://home.inreach.com/mdunn/ Ford: How would you react if I said that I'm not from Guildford after all, but from a small planet somewhere in the vicinity of Betelguese? Arthur: I don't know. Why, do you think it's the sort of thing you're likely to say?

      K 1 Reply Last reply
      0
      • K Ken Goguen

        I have a strange one. I have my own CTreeCtrl for doing multi-select. When build/run a debug version it works just fine. When I build/run a release version, my tree nodes get populated, but I do not see any + on the parent nodes and cannot expand them to see the children. But I can do all that in the debug version without a problem. Any Ideas? :eek: -kg // *** TreeView CMulSelTreeCtrl* pMyTree = (CMulSelTreeCtrl*) GetDlgItem(IDC_TREE1); ASSERT(pMyTree != NULL); pMyTree ->DeleteAllItems(); pMyTree ->ModifyStyle(NULL, TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS); // Associate the image list with the tree control. pMyTree ->SetImageList(pilMyTree, TVSIL_NORMAL); TVINSERTSTRUCT tvInsert; tvInsert.hParent = NULL; tvInsert.hInsertAfter = NULL; tvInsert.item.mask = TVIF_TEXT | TVIF_CHILDREN; // *** TreeView tvInsert.item.pszText = _T(buffer); HTREEITEM hTreeItem = pMyTree ->InsertItem(&tvInsert); Ken Goguen Principle Design Engineer EMC Corporation

        T Offline
        T Offline
        Tomasz Sowinski
        wrote on last edited by
        #3

        The code you've posted only inserts a root item. And TVIF_CHILDREN flag is ignored during inserts. It works when you're getting information about the item with GetItem. BTW: why are you using a InsertItem overload that takes TVINSERTSTRUCT - there are more convenient versions. Tomasz Sowinski -- http://www.shooltz.com

        K 1 Reply Last reply
        0
        • M Michael Dunn

          Init your structs to zero before using them: TVINSERTSTRUCT tvInsert = {0}; --Mike-- http://home.inreach.com/mdunn/ Ford: How would you react if I said that I'm not from Guildford after all, but from a small planet somewhere in the vicinity of Betelguese? Arthur: I don't know. Why, do you think it's the sort of thing you're likely to say?

          K Offline
          K Offline
          Ken Goguen
          wrote on last edited by
          #4

          Good practice, but didn't resolve the problem. -kg Ken Goguen Principle Design Engineer EMC Corporation

          1 Reply Last reply
          0
          • T Tomasz Sowinski

            The code you've posted only inserts a root item. And TVIF_CHILDREN flag is ignored during inserts. It works when you're getting information about the item with GetItem. BTW: why are you using a InsertItem overload that takes TVINSERTSTRUCT - there are more convenient versions. Tomasz Sowinski -- http://www.shooltz.com

            K Offline
            K Offline
            Ken Goguen
            wrote on last edited by
            #5

            There is additional code that adds the other nodes, but using message windows I've been able to determine that the expand problem occurs on the first insert. Only using the overload as it was part of an old example I began with. Do you think this could be part of the problem? -kg Ken Goguen Principle Design Engineer EMC Corporation

            T 1 Reply Last reply
            0
            • K Ken Goguen

              There is additional code that adds the other nodes, but using message windows I've been able to determine that the expand problem occurs on the first insert. Only using the overload as it was part of an old example I began with. Do you think this could be part of the problem? -kg Ken Goguen Principle Design Engineer EMC Corporation

              T Offline
              T Offline
              Tomasz Sowinski
              wrote on last edited by
              #6

              There are many fields in TVITEM struct, which is a member of TVINSERTSTRUCT. You may have overlooked one of them. Give other overloads a try - they are easier to use and understand. Tomasz Sowinski -- http://www.shooltz.com

              K 1 Reply Last reply
              0
              • T Tomasz Sowinski

                There are many fields in TVITEM struct, which is a member of TVINSERTSTRUCT. You may have overlooked one of them. Give other overloads a try - they are easier to use and understand. Tomasz Sowinski -- http://www.shooltz.com

                K Offline
                K Offline
                Ken Goguen
                wrote on last edited by
                #7

                I simplified as follows and it seems to have done the trick. Thanks. HTREEITEM hTreeItem = pMyTree->InsertItem(_T(buffer),0,0,NULL, TVI_LAST); :-D -kg Ken Goguen Principle Design Engineer EMC Corporation

                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