Q: How to detect which part of an item the user clicked on?
A: It does not matter whether we're talking about a left click, a right click or just hoovering with the mouse. IOW, the message you handle is irrelevant - the method of detecting what exactly is under the cursor is the same:
Code:void CYourDialog::OnClickTree(NMHDR* pNMHDR, LRESULT* pResult) { CPoint point; UINT uFlags; HTREEITEM hItem; GetCursorPos(&point); m_tree.ScreenToClient(&point); hItem = m_tree.HitTest(point, &uFlags); if(hItem) { // There is an item under the cursor. // See what exactly was under the cursor: switch(uFlags) { case TVHT_ONITEMSTATEICON: // It was the icon break; case TVHT_ONITEMBUTTON: // It was the button break; // ...and so on } } *pResult = 0; }




Reply With Quote