CTreeCtrl::GetSelectedItem

调用该函数检索树视图控件的当前选定项。

HTREEITEM GetSelectedItem( ) const;

返回值

选定项的句柄;否则 NULL

示例

// Expand the selected item and make it visible, if possible.
HTREEITEM hItem = m_TreeCtrl.GetSelectedItem();

if ((hItem != NULL) && m_TreeCtrl.ItemHasChildren(hItem))
{
   m_TreeCtrl.Expand(hItem, TVE_EXPAND);
   m_TreeCtrl.EnsureVisible(hItem);
}

要求

Header: afxcmn.h

请参见

参考

CTreeCtrl Class

层次结构图

CTreeCtrl::Select

CTreeCtrl::SelectDropTarget

CTreeCtrl::GetDropHilightItem