I guess u r using GetSelectedItem() within NM_RCLICK handler. The default
behaviour of TreeCtrl does'nt select an item on getting RClick.
Try the following code, it worked for me
void CMyTreeCtrl::OnRclick(NMHDR* pNMHDR, LRESULT* pResult)
{
CPoint pt;
GetCursorPos(&pt);
ScreenToClient(&pt);
UINT flags;
HTREEITEM hItem = HitTest( pt, &flags );
if ( hItem &&
flags & TVHT_ONITEM )
{
MessageBox( GetItemText(hItem) );
}
*pResult = 0;
}
hth
Thangaraj A.L.
> Hello!
>
[quoted text clipped - 9 lines]
> How can I right click on the third one and get its name out of it? Does
> anyone know?
Lars Gr?tteland - 07 May 2004 08:47 GMT
WOW
Thanks very much!
Could I ask you another one. If I drag an item in the tree - I would like it
to change place with that one I drag it over? How do I do that?
- Lars

Signature
- Lars
> I guess u r using GetSelectedItem() within NM_RCLICK handler. The default
> behaviour of TreeCtrl does'nt select an item on getting RClick.
[quoted text clipped - 38 lines]
> > How can I right click on the third one and get its name out of it? Does
> > anyone know?
if you are trying to display selected item in OnRButtonDown before anything
happens then previous one would be still selected... If you are doing that
then perhaps you should put the same msg box on OnRButtonUp..
> Hello!
>
[quoted text clipped - 9 lines]
> How can I right click on the third one and get its name out of it? Does
> anyone know?