CTreeCtrl::GetItemRect

BOOL GetItemRect( HTREEITEM hItem, LPRECT lpRect, BOOL bTextOnly );

Return Value

Nonzero if the item is visible, with the bounding rectangle contained in lpRect. Otherwise, 0 with lpRect uninitialized.

Parameters

hItem

The handle of a tree view control item.

lpRect

Pointer to a RECT structure that receives the bounding rectangle. The coordinates are relative to the upper-left corner of the tree view control.

bTextOnly

If this parameter is nonzero, the bounding rectangle includes only the text of the item. Otherwise it includes the entire line that the item occupies in the tree view control.

Remarks

Call this function to retrieve the bounding rectangle for hItem and determine whether it is visible or not.

Example

// The pointer to my tree control.
extern CTreeCtrl* pmyTreeCtrl;
// The item whose bounds we want.
extern HTREEITEM hmyItem;

// Dump the bounds of hmyItem.
#ifdef _DEBUG
if (hmyItem != NULL)
{
   CString str;
   RECT r;

   pmyTreeCtrl->GetItemRect(hmyItem, &r, FALSE);

   str.Format(TEXT("left = %d, top = %d, right = %d, bottom = %d\r\n"),
      r.left,
      r.top,
      r.right,
      r.bottom);
   afxDump << str;
}

CTreeCtrl OverviewClass MembersHierarchy Chart

See Also   CTreeCtrl::GetVisibleCount, CTreeCtrl::GetNextVisibleItem, CTreeCtrl::GetPrevVisibleItem, CTreeCtrl::EnsureVisible