MFC中CTreeCtrl展开树形列表节点

 
 
void CMenuCreatDlg::OnMENUITEMexpandtree() //展开所有节点
{
    // TODO: Add your command handler code here
     MyExpandTree(m_tree.GetRootItem()); 
}
 
void CMenuCreatDlg::MyExpandTree(HTREEITEM hTreeItem)
{
    if(!m_tree.ItemHasChildren(hTreeItem))
    {
        return;
    }
    HTREEITEM hNextItem = m_tree.GetChildItem(hTreeItem);
    while (hNextItem != NULL)
    {
        MyExpandTree(hNextItem);
        hNextItem = m_tree.GetNextItem(hNextItem, TVGN_NEXT);
    }
    m_tree.Expand(hTreeItem,TVE_EXPAND);
}

你可能感兴趣的:(2008,CTreeCtrl,展开树形列表所有节点)