CTreeCtrl控件中递归删除节点

类别:编程语言 点击:0 评论:0 推荐:
HTREEITEM CMyTree::DelChild( HTREEITEM hItem )
{
     HTREEITEM hPare = NULL;
     if( !ItemHasChildren(hItem) )
     {
          if( m_iCount >= 0 )
          m_iCount--; //静态成员变量
          hPare = GetParentItem( hItem );
          TRACE( "Delete: %s\n", GetItemText( hItem ) );
          DeleteItem( hItem );
          return ( m_iCount >= 0 ) ? DelChild( hPare ) : NULL;
 }
 else
 {
      ++m_iCount;
      TRACE( "Node:%s\n",GetItemText( hItem ) );
      return DelChild( GetNextItem( hItem, TVGN_CHILD ) );
 }
 
}

本文地址:http://com.8s8s.com/it/it23541.htm