Share via


CTreeCtrl::HitTest

Call this function to determine the location of the specified point relative to the client area of a tree view control.

HTREEITEM HitTest( 
   CPoint pt, 
   UINT* pFlags = NULL 
) const; 
HTREEITEM HitTest( 
   TVHITTESTINFO* pHitTestInfo  
) const;

Parameters

  • pt
    Client coordinates of the point to test.

  • pFlags
    Pointer to an integer that receives information about the results of the hit test. It can be one or more of the values listed under the flags member in the Remarks section.

  • pHitTestInfo
    Address of a TVHITTESTINFO structure that contains the position to hit test and that receives information about the results of the hit test.

Return Value

The handle of the tree view item that occupies the specified point or NULL if no item occupies the point.

Remarks

When this function is called, the pt parameter specifies the coordinates of the point to test. The function returns the handle of the item at the specified point or NULL if no item occupies the point. In addition, the pFlags parameter contains a value that indicates the location of the specified point.

Example

// Select the item that is at the point myPoint.
UINT uFlags;
HTREEITEM hItem = m_TreeCtrl.HitTest(myPoint, &uFlags);

if ((hItem != NULL) && (TVHT_ONITEM & uFlags))
{
   m_TreeCtrl.SelectItem(hItem);
}

Requirements

Header: afxcmn.h

See Also

Reference

CTreeCtrl Class

Hierarchy Chart

CTreeCtrl::GetItemRect

Other Resources

CTreeCtrl Members