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