CTreeCtrl::GetNextItem

HTREEITEM GetNextItem( HTREEITEM hItem, UINT nCode );

Return Value

The handle of the next item if successful; otherwise NULL.

Parameters

hItem

Handle of a tree item.

nCode

A flag indicating the type of relation to hItem. This flag can be one of the following values:

Remarks

Call this function to retrieve the tree view item that has the specified relationship, indicated by the nCode parameter, to hItem.

Example

For an example of using GetNextItem in a loop, see CTreeCtrl::DeleteItem.

// Gain a pointer to our tree control
CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE1);
ASSERT(pCtrl != NULL);

// find the currently selected item
HTREEITEM hCurSel = pCtrl->GetNextItem(TVI_ROOT, TVGN_CARET);

// report it to the user
if (hCurSel == NULL)
   MessageBox(_T("There is no selected item"));
else
{
   CString str;
   str.Format(_T("The currently selected item is \"%s\""),
      (LPCTSTR) pCtr->GetItemText(hCurSel));
   MessageBox((LPCTSTR) str);
}

CTreeCtrl OverviewClass MembersHierarchy Chart

See Also   CTreeCtrl::SetItem, CTreeCtrl::GetChildItem, CTreeCtrl::GetItem, CTreeCtrl::SelectItem, CTreeCtrl::GetPrevSiblingItem