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. Quickest way to get childern of CTreeCtr

Quickest way to get childern of CTreeCtr

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structureshelp
6 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.
  • G Offline
    G Offline
    generic_user_id
    wrote on last edited by
    #1

    What is the best way to get the number of items from a 'branch' of a tree control, so I can put a number in brackets behind the name of the parent. ROOT - People (2) * Paul * John - Kids (3) * Jack * Tom * William So in this case I want to know how many items have "people" as parent. (that's two) GetCount() returns the total number of counts, so that's useless. Also, how can I change the name of an already existing item in a treeview? Who can help me out? Cheers!

    G 1 Reply Last reply
    0
    • G generic_user_id

      What is the best way to get the number of items from a 'branch' of a tree control, so I can put a number in brackets behind the name of the parent. ROOT - People (2) * Paul * John - Kids (3) * Jack * Tom * William So in this case I want to know how many items have "people" as parent. (that's two) GetCount() returns the total number of counts, so that's useless. Also, how can I change the name of an already existing item in a treeview? Who can help me out? Cheers!

      G Offline
      G Offline
      generic_user_id
      wrote on last edited by
      #2

      [nt]

      T 1 Reply Last reply
      0
      • G generic_user_id

        [nt]

        T Offline
        T Offline
        Tom Archer
        wrote on last edited by
        #3

        While many of us know the solution, it would be great if you could share your solution as well. That way, another person searching for this will find a complete solution. Besides, you might have come up with a unique way of completing the task that would teach us all. Cheers, Tom Archer Author, Inside C# Author, Visual C++.NET Bible A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af

        G 1 Reply Last reply
        0
        • T Tom Archer

          While many of us know the solution, it would be great if you could share your solution as well. That way, another person searching for this will find a complete solution. Besides, you might have come up with a unique way of completing the task that would teach us all. Cheers, Tom Archer Author, Inside C# Author, Visual C++.NET Bible A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af

          G Offline
          G Offline
          generic_user_id
          wrote on last edited by
          #4

          HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

          CBitmap bitmap;
          CBrush brush;

          bitmap.LoadBitmap(IDB_BACKG);

          int nCtrl = pWnd->GetDlgCtrlID();
          pDC->SetBkColor(RGB_VALUE);

          if ( NULL != brush.m_hObject )
          ::DeleteObject(brush);

          brush.CreatePatternBrush(&bitmap);
          hbr = brush;
          return hbr;

          This is not written by me though, I read something like this somewhere else.

          T 1 Reply Last reply
          0
          • G generic_user_id

            HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

            CBitmap bitmap;
            CBrush brush;

            bitmap.LoadBitmap(IDB_BACKG);

            int nCtrl = pWnd->GetDlgCtrlID();
            pDC->SetBkColor(RGB_VALUE);

            if ( NULL != brush.m_hObject )
            ::DeleteObject(brush);

            brush.CreatePatternBrush(&bitmap);
            hbr = brush;
            return hbr;

            This is not written by me though, I read something like this somewhere else.

            T Offline
            T Offline
            Tom Archer
            wrote on last edited by
            #5

            Um...what does this have to do with getting the children of a HTREEITEM :) Cheers, Tom Archer Author - Inside C#, Visual C++.NET Bible A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af

            G 1 Reply Last reply
            0
            • T Tom Archer

              Um...what does this have to do with getting the children of a HTREEITEM :) Cheers, Tom Archer Author - Inside C#, Visual C++.NET Bible A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af

              G Offline
              G Offline
              generic_user_id
              wrote on last edited by
              #6

              Oops, I answered the wrong question of myself here. :) My solution to this one was pretty cheap, I just made a counter (structure with HTREEITEM and an INT) and every time an item was added to a part of a tree I updated the counter. As the user could not add or delete things from the tree, this solution worked quite well. I used GetItemtext(..), added "(%d)" to the string and set the new string with SetItem(..) But I take it this was not the 'obvious' solution :)

              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