void CFileView::BulidTreeView( HTREEITEM tree_node)
{
//我的控制类
MySingletonManager& my_manager = MySingletonManager::GetSingleton( );
//通过名字找到我的对象
MyStaff* my_staff = my_manager .SearchStaff(mTreeControl.GetItemText(tree_node).GetBuffer(0) );
//遍历这个对象的所有孩子,并添加至TreeControl
for(unsigned int i=0; i< my_staff->mChilds.Number(); i++)
{
MyStaff* child_staff = my_manager.GetStaff(my_staff->mChilds[i]);//查找
HTREEITEM child_node = mTreeControl.InsertItem( child_staff->mName.c_str() ,tree_node);//添加
// 孩子有孩子么?
if(child_staff->mChilds.Number() >0 )
{
BulidTreeView(child_node);//递归
}
}
mTreeControl.Expand(tree_node, TVE_EXPAND); // 展开节点
}
MySingletonManager:类的单件注册表
MyStaff:类,互相之间可能有父子关系