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. Other Discussions
  3. Site Bugs / Suggestions
  4. How to GetItemText from a TreeView using right click?

How to GetItemText from a TreeView using right click?

Scheduled Pinned Locked Moved Site Bugs / Suggestions
data-structurestutorialquestion
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
    Lost User
    wrote on last edited by
    #1

    Presently, I manage to do that when I first click on the left mouse button to select the HTREEITEM and then click on the right to bring up a message box showing the value of selected item text. How to GetItemText from a tree view using right click without using the left one first? Thanks. YC

    S 1 Reply Last reply
    0
    • L Lost User

      Presently, I manage to do that when I first click on the left mouse button to select the HTREEITEM and then click on the right to bring up a message box showing the value of selected item text. How to GetItemText from a tree view using right click without using the left one first? Thanks. YC

      S Offline
      S Offline
      Sandra
      wrote on last edited by
      #2

      To your class derived from TreeView add to the message handler //{{AFX_MSG(CMyTreeView) afx_msg void OnRButtonDown(UINT nFlags, CPoint point); //}}AFX_MSG Implement the function OnRButtonDown as following void CMyTreeView::OnLButtonDown(UINT nFlags, CPoint point) { UINT uFlags; HTREEITEM hItem = GetTreeCtrl().HitTest(point, &uFlags); if ((hItem != NULL) && (uFlags & TVHT_ONITEM)) { CString strText = GetTreeCtrl().GetItemText(hItem); AfxMessageBox(strText); } }

      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