CTreeCtrl: How to cath the Mouse Click on an item?
Posted on 2003-12-11
I am trying to catch the Mouse Click event on a node item of a CTreeCtrl, but I have trouble getting the HTREEITEM refering to the node item that has been clicked.
I mapped the following message:
ON_NOTIFY(NM_CLICK, IDC_MY_TREE_CTRL, OnClickMyTreeCtrl)
And have the following function:
void CMyDialog::OnClickMyTreeCtrl(NMHDR* pNMHDR, LRESULT* pResult)
HTREEITEM lNodeItem = ((NM_TREEVIEW*)pNMHDR)->itemNew.hItem;
*pResult = 0;
But lNodeItem is always NULL.
And if I try this:
It is the item that was previously selected before the click event.
Any ideas on how I could get the HTREEITEM when a node item is clicked?