Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   get node handle when Tree node clicked CTreeCtrl (http://www.go4expert.com/forums/node-handle-tree-node-clicked-ctreectrl-t19272/)

salini_s 2Sep2009 19:06

get node handle when Tree node clicked CTreeCtrl
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

OnNMClickSampleTree(NMHDR *pNMHDR, LRESULT *pResult)
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?

All times are GMT +5.5. The time now is 04:08.