CTreeCtrl控件使用技巧

一、CTreeCtrl::GetRootItem

      Call this function to retrieve the root item of the tree view control.

         HTREEITEM GetRootItem( ) const;

二、CTreeCtrl::GetItemText

      

      Returns the text of the item specified by hItem.

      

        CString GetItemText(
               HTREEITEM hItem 
        ) const;
三、CTreeCtrl::GetNextItem 

      Call this function to retrieve the tree view item that has the 
specified relationship, indicated by the nCode parameter, to 
hItem. 
 
       HTREEITEM GetNextItem(
                HTREEITEM hItem,
                UINT nCode 
       ) const;
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 of the item specified by the hItem parameter.

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

  • TVGN_FIRSTVISIBLE   Retrieves the first visible item.

  • TVGN_LASTVISIBLE   Retrieves the last expanded item in the tree. This does not retrieve the last item visible in the tree-view window.

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

四、CTreeCtrl::ItemHasChildren 

Use this function to determine whether the tree item specified by hItem has child items.

BOOL ItemHasChildren(
   HTREEITEM hItem 
) const;
五、CTreeCtrl::GetChildItem

Call this function to retrieve the tree view item that is the child of the item specified by hItem.

HTREEITEM GetChildItem(
   HTREEITEM hItem 
) const;

原文地址:https://www.cnblogs.com/johnpher/p/2570706.html