1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

get node handle when Tree node clicked CTreeCtrl

Discussion in 'C' started by salini_s, Sep 2, 2009.

Thread Status:
Not open for further replies.
  1. salini_s

    salini_s Banned

    Joined:
    Sep 2, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi All,

    I want to get the handle of a tree node when a user clicks on it. i am using CTreeCtrl and handling the click event in OnNMClickSampleTree().

    I got a few methods to do it from internet, unfortunately none works. i paste them below

    Method 1: getting the mouse pointer co-ordinate and using HitTest() function

    eg:
    OnNMClickSampleTree(NMHDR *pNMHDR, LRESULT *pResult)
    {
    GetCursorPos(&myPoint);
    ScreenToClient(&myPoint);
    HTREEITEM clickedNode = SampleTree.HitTest(myPoint,&uFlags);

    }
    i am getting some handle, but it is not of the item that i clicked.

    Method2 - from the pNMHDR structure.

    OnNMClickSampleTree(NMHDR *pNMHDR, LRESULT *pResult)
    {
    HTREEITEM clickedNode = ((NM_TREEVIEW*)pNMHDR)->itemNew.hItem;
    }

    unfortunately this also doesn't work. can any see what is going wrong here?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,293
    Likes Received:
    365
    Trophy Points:
    83
Thread Status:
Not open for further replies.

Share This Page