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. C / C++ / MFC
  3. LPARAM associated data in TVITEM in TreeCtrl

LPARAM associated data in TVITEM in TreeCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
4 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.
  • U Offline
    U Offline
    User 10281465
    wrote on last edited by
    #1

    If someone can explain the following I would appreciate it. I have a simple Tree control in which I need to associate data with individual items in the tree. The 32 bit LParam seems like an easy place to place an identifier that I can then use to lookup the assoicated data in a secondary array (or what ever). When I try to directly use this field it appears to always be blank (zero). But when I use the SetItemData function with the item handle returned in from the InsertItem function all works fine. HTREEITEM pItem = m_ProdTree.InsertItem("My Text",pRoot,NULL); DWORD MyNum=nnn; m_ProdTree.SetItemData(pPar,MyNum); Doesn't the SetItemData/GetItemData use the LParam field?? Thanks Mike

    U M 2 Replies Last reply
    0
    • U User 10281465

      If someone can explain the following I would appreciate it. I have a simple Tree control in which I need to associate data with individual items in the tree. The 32 bit LParam seems like an easy place to place an identifier that I can then use to lookup the assoicated data in a secondary array (or what ever). When I try to directly use this field it appears to always be blank (zero). But when I use the SetItemData function with the item handle returned in from the InsertItem function all works fine. HTREEITEM pItem = m_ProdTree.InsertItem("My Text",pRoot,NULL); DWORD MyNum=nnn; m_ProdTree.SetItemData(pPar,MyNum); Doesn't the SetItemData/GetItemData use the LParam field?? Thanks Mike

      U Offline
      U Offline
      Uwe Keim
      wrote on last edited by
      #2

      Maybe you have not set the flags in the TVITEM structure correctly? Try to debug into the SetItemData() member function and look how MFC does it. Then you can do it the same way.

      M 1 Reply Last reply
      0
      • U Uwe Keim

        Maybe you have not set the flags in the TVITEM structure correctly? Try to debug into the SetItemData() member function and look how MFC does it. Then you can do it the same way.

        M Offline
        M Offline
        michael 0
        wrote on last edited by
        #3

        Thanks, Good idea.

        1 Reply Last reply
        0
        • U User 10281465

          If someone can explain the following I would appreciate it. I have a simple Tree control in which I need to associate data with individual items in the tree. The 32 bit LParam seems like an easy place to place an identifier that I can then use to lookup the assoicated data in a secondary array (or what ever). When I try to directly use this field it appears to always be blank (zero). But when I use the SetItemData function with the item handle returned in from the InsertItem function all works fine. HTREEITEM pItem = m_ProdTree.InsertItem("My Text",pRoot,NULL); DWORD MyNum=nnn; m_ProdTree.SetItemData(pPar,MyNum); Doesn't the SetItemData/GetItemData use the LParam field?? Thanks Mike

          M Offline
          M Offline
          michael 0
          wrote on last edited by
          #4

          Just to document: I was not setting the mask correctly. I had just set the mask to TVIF_TEXT and had not added the TVIF_PARAM. TVINSERTSTRUCT MyInsert; MyInsert.hParent=NULL; MyInsert.hInsertAfter=NULL; MyInsert.item.mask=TVIF_TEXT|TVIF_PARAM; // <<< HERE // The mask defines what is valid !! MyInsert.item.pszText=_T("A->Root"); MyInsert.item.lParam=(LPARAM)MyDataValue; HTREEITEM TVI_MyItem = m_Tree.InsertItem(&MyInsert);

          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