Поделиться через


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;

Параметры

  • 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.

Возвращаемое значение

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

Заметки

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.

Пример

// 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);
}

Требования

Header: afxcmn.h

См. также

Основные понятия

CTreeCtrl Class

CTreeCtrl Members

Hierarchy Chart

CTreeCtrl::GetItemRect