CTreeCtrl::GetNextItem

HTREEITEMGetNextItem(HTREEITEMhItem**,UINTnCode);**

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:

  • TVGN_CARET   Retrieves the currently selected item.

  • TVGN_CHILD   Retrieves the first child item. The hItem parameter must be NULL.

  • TVGN_DROPHILITE   Retrieves the item that is the target of a drag-and-drop operation.

  • TVGN_FIRSTVISIBLE   Retrieves the first visible item.

  • TVGN_NEXT   Retrieves the next sibling item.

  • TVGN_NEXTVISIBLE   Retrieves the next visible item that follows the specified item.

  • TVGN_PARENT   Retrieves the parent of the specified item.

  • TVGN_PREVIOUS   Retrieves the previous sibling item.

  • TVGN_PREVIOUSVISIBLE   Retrieves the first visible item that precedes the specified item.

  • TVGN_ROOT   Retrieves the first child item of the root item of which the specified item is a part.

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