Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Making the Treeview just like Explorer Collapse All
Subject Author Date
Saroj Acharya Apr 12, 2005 - 8:59 AM

Hi Technical Support,


I am using a treeview from your sample application for my application and it working great. However, I have noticed few limitations with this and would like to seek your help.


When you right click on an item currently not selected, the selection momentorialy goes to the new selection and then goes back to the old selection when the Pop-up menu is displayed. This is a probelm for me because I wanted to make the selection where the Right mouse button was clicked. Can you help me to resolve this problem ?


I noticed similar behaviour in your sample applications as well.


I appreciate your help.


Regards,


Saroj

Technical Support Apr 12, 2005 - 10:15 AM

The behavior you described is standard for the tree control. When you receive the right mouse click message (or WM_CONTEXTMENU) you can get coordinates of the mouse pointer, call the HitTest method to determine the tree item at the specified point, and select it by hand. This will allow you make the item selected after the pop-up menu is closed.

void CMyTree::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) 
{
   UINT nFlags;
   CPoint curPoint;
   GetCursorPos(&curPoint);
   ScreenToClient(&curPoint);
 
   HTREEITEM hCurrentItem = HitTest(curPoint, &nFlags);
   if(hCurrentItem != NULL)
   {
      SelectItem(hCurrentItem) ;
 
// show context menu
      }
*pResult = 1;
}

Saroj Acharya Apr 18, 2005 - 1:58 PM

It worked as I wanted. Thanks,


Saroj