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. Tree Control Question

Tree Control Question

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestiondata-structures
5 Posts 3 Posters 7 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.
  • R Offline
    R Offline
    Richard Cheng
    wrote on last edited by
    #1

    I have the following tree: .ABC .|_A .|_B .|_C .XYZ .|_X ...|_XX .|_Y .|_Z I want to display something when i use a mouse to click on particular item. How to do that? For example, if I highlight XX, then pop up a message box say "XX"....etc... Thanks

    T N 2 Replies Last reply
    0
    • R Richard Cheng

      I have the following tree: .ABC .|_A .|_B .|_C .XYZ .|_X ...|_XX .|_Y .|_Z I want to display something when i use a mouse to click on particular item. How to do that? For example, if I highlight XX, then pop up a message box say "XX"....etc... Thanks

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Handle the NM_CLICK notification. You can implement the handler in the parent dialog box or (using message reflection) in CTreeCtrl-derived class. Tomasz Sowinski -- http://www.shooltz.com.pl

      R 1 Reply Last reply
      0
      • T Tomasz Sowinski

        Handle the NM_CLICK notification. You can implement the handler in the parent dialog box or (using message reflection) in CTreeCtrl-derived class. Tomasz Sowinski -- http://www.shooltz.com.pl

        R Offline
        R Offline
        Richard Cheng
        wrote on last edited by
        #3

        Thanks for your reply. I know I can use NM_CLICK, but I don't know which function in CTreeCtrl i should use. Seems liked they just return a HTREEITEM variable. The following is how i make a tree: HTREEITEM ABC, XYZ, node; ABC = m_Tree.InsertItem("ABC", TVI_ROOT); node = m_Tree.InsertItem("A", ABC); node = m_Tree.InsertItem("B", ABC); ...etc... if I want to choose B...but it returns a HTREEITEM....how can i know which "node"....

        T 1 Reply Last reply
        0
        • R Richard Cheng

          Thanks for your reply. I know I can use NM_CLICK, but I don't know which function in CTreeCtrl i should use. Seems liked they just return a HTREEITEM variable. The following is how i make a tree: HTREEITEM ABC, XYZ, node; ABC = m_Tree.InsertItem("ABC", TVI_ROOT); node = m_Tree.InsertItem("A", ABC); node = m_Tree.InsertItem("B", ABC); ...etc... if I want to choose B...but it returns a HTREEITEM....how can i know which "node"....

          T Offline
          T Offline
          Tomasz Sowinski
          wrote on last edited by
          #4

          Use GetMessagePos and CTreeCtrl::HitTest. Assuming that you're handling NM_CLICK in CTreectrl-derived object, you'd write your code like this: CPoint pt = ::GetMessagePos(); ScreenToClient(&pt); UINT flags; HTREEITEM hItem; hItem = HitTest(pt, &flags); And do whatever you want with hItem and flags. Tomasz Sowinski -- http://www.shooltz.com.pl

          1 Reply Last reply
          0
          • R Richard Cheng

            I have the following tree: .ABC .|_A .|_B .|_C .XYZ .|_X ...|_XX .|_Y .|_Z I want to display something when i use a mouse to click on particular item. How to do that? For example, if I highlight XX, then pop up a message box say "XX"....etc... Thanks

            N Offline
            N Offline
            netsky
            wrote on last edited by
            #5

            Please use TVN_SELCHANGED, ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelchanged) OnSelchanged is a Function. welcome you to Sky...

            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