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. CTreeCtrl GetSelectedItem()

CTreeCtrl GetSelectedItem()

Scheduled Pinned Locked Moved C / C++ / MFC
data-structures
2 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.
  • L Offline
    L Offline
    laiju
    wrote on last edited by
    #1

    I tried to get the currently clicked item on the tree ctrl using the foll. code But it does not return me the current item. What could be wrong void COSDDlgBar::OnNMClickTree1(NMHDR *pNMHDR, LRESULT *pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; CTreeCtrl *pm_Tree = NULL; pm_Tree = (CTreeCtrl*)GetDlgItem(IDC_TREE1); HTREEITEM hItem = pm_Tree->GetSelectedItem(); *pResult = 0; } laiju

    J 1 Reply Last reply
    0
    • L laiju

      I tried to get the currently clicked item on the tree ctrl using the foll. code But it does not return me the current item. What could be wrong void COSDDlgBar::OnNMClickTree1(NMHDR *pNMHDR, LRESULT *pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; CTreeCtrl *pm_Tree = NULL; pm_Tree = (CTreeCtrl*)GetDlgItem(IDC_TREE1); HTREEITEM hItem = pm_Tree->GetSelectedItem(); *pResult = 0; } laiju

      J Offline
      J Offline
      Jack Puppy
      wrote on last edited by
      #2

      I don't think the selection will change until after the NM_CLICK has been processed. Try handling TVN_SELCHANGED and call your code from there. (or better yet, use the itemNew variable in the NM_TREEVIEW struct)

      :suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!

      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