Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to retrieve what item has been clicked on in the treeview

C++
void CListaDevice::OnClickTree(NMHDR* pNMHDR, LRESULT* pResult) {

	*pResult = FALSE; 

     CPoint pt;
     GetCursorPos( &pt );
     m_wndTreeDevice.ScreenToClient( &pt ) ;
     
     UINT nFlags = 0;
     HTREEITEM hItem = m_wndTreeDevice.HitTest( pt, &nFlags ) ;
     if( hItem == NULL  ||  !(nFlags & (TVHT_ONITEMLABEL|TVHT_ONITEMICON)) )
		return;
//hItem is always 0x0000!!!

}


what am I doing wrong?
Posted
Updated 23-Feb-12 0:20am
v3

1 solution

I solved using TVN_SELCHANGED event

but however before or later, I will have to test what item has been clicked in the NM_CLICK message
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900