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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to add and retrive the LPARAM value from CTreeCtrl?

How to add and retrive the LPARAM value from CTreeCtrl?

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structurestutorial
5 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.
  • M Offline
    M Offline
    mikert_2008
    wrote on last edited by
    #1

    Hi, I am useing CTreeCtrl class to build tree. I want to add CString as a additional parameter(LPARAM) to leaf node. How can I add/retrive LPARAM? For Insertion I am Using:- tree.InsertItem("Employees", 0, 0, TVI_ROOT); And For retrival I Am using:- HTREEITEM hCurSel = tree.GetNextItem(TVI_ROOT, TVGN_CARET); Please suggest If I need to use different method for it or modify above method for add/Retrive LPARAM. Thanks:- Mike

    CPalliniC C 2 Replies Last reply
    0
    • M mikert_2008

      Hi, I am useing CTreeCtrl class to build tree. I want to add CString as a additional parameter(LPARAM) to leaf node. How can I add/retrive LPARAM? For Insertion I am Using:- tree.InsertItem("Employees", 0, 0, TVI_ROOT); And For retrival I Am using:- HTREEITEM hCurSel = tree.GetNextItem(TVI_ROOT, TVGN_CARET); Please suggest If I need to use different method for it or modify above method for add/Retrive LPARAM. Thanks:- Mike

      CPalliniC Online
      CPalliniC Online
      CPallini
      wrote on last edited by
      #2

      What about SetItemData[^] and GetItemData [^] methods? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      M 1 Reply Last reply
      0
      • CPalliniC CPallini

        What about SetItemData[^] and GetItemData [^] methods? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        M Offline
        M Offline
        mikert_2008
        wrote on last edited by
        #3

        Hi, I am not sure about SetItemData() and GetItemData() will solve my purpose. I want to send some CString value with each leaf node. e.g If you insert node 'Employee1' in the tree I will add 'EmployeeId1' as a LPARAM. So that next time when i retrive the node data I need to get LPARAM(Id associated with leaf node) somehow. Please suggest how this can achive? Thanks:- Mike

        CPalliniC 1 Reply Last reply
        0
        • M mikert_2008

          Hi, I am not sure about SetItemData() and GetItemData() will solve my purpose. I want to send some CString value with each leaf node. e.g If you insert node 'Employee1' in the tree I will add 'EmployeeId1' as a LPARAM. So that next time when i retrive the node data I need to get LPARAM(Id associated with leaf node) somehow. Please suggest how this can achive? Thanks:- Mike

          CPalliniC Online
          CPalliniC Online
          CPallini
          wrote on last edited by
          #4

          mikert_2008 wrote:

          I am not sure about SetItemData() and GetItemData() will solve my purpose.

          I'm pretty confident about (I trust in your skills :rolleyes:). With SetItemData you may store a pointer to your string (the string should not vanish in the meantime...). With GetItemData you may get back such pointer. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • M mikert_2008

            Hi, I am useing CTreeCtrl class to build tree. I want to add CString as a additional parameter(LPARAM) to leaf node. How can I add/retrive LPARAM? For Insertion I am Using:- tree.InsertItem("Employees", 0, 0, TVI_ROOT); And For retrival I Am using:- HTREEITEM hCurSel = tree.GetNextItem(TVI_ROOT, TVGN_CARET); Please suggest If I need to use different method for it or modify above method for add/Retrive LPARAM. Thanks:- Mike

            C Offline
            C Offline
            Code o mat
            wrote on last edited by
            #5

            As CPallini suggested, you should use SetItemData and GetItemData, these can store and retrieve a 32 (or 64?) bit value, so you can't use a string, BUT you can either use a pointer to a string OR maybe an index into an array of strings, of course you will have to maintain these somehow, so if you remove an item you also manually need to remove the string or when you add the item you will have to add the string.

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

            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