我用递归做的,请帮我看看。树节点只有几十个的时候能遍历全部,但是当节点有3000多个时,就只能遍历2000左右了。void CMyTreeCtrl::ExploreTreeItem(HTREEITEM hTreeItem)
{
CString strNode;
HTREEITEM hFirstChild = NULL; // Get the first child
hFirstChild = GetNextItem(hTreeItem, TVGN_CHILD); // Keep going until we have all of them
while(hFirstChild)
{
// get the current indention level
strNode = GetItemText(hFirstChild);
if(NULL != pTemp)
{
TRACE("Explore node = %s\n", strNode);
}
// Recusively get all of the child items
ExploreTreeItem(hFirstChild);
hFirstChild = GetNextItem(hFirstChild, TVGN_NEXT);
}
}
{
CString strNode;
HTREEITEM hFirstChild = NULL; // Get the first child
hFirstChild = GetNextItem(hTreeItem, TVGN_CHILD); // Keep going until we have all of them
while(hFirstChild)
{
// get the current indention level
strNode = GetItemText(hFirstChild);
if(NULL != pTemp)
{
TRACE("Explore node = %s\n", strNode);
}
// Recusively get all of the child items
ExploreTreeItem(hFirstChild);
hFirstChild = GetNextItem(hFirstChild, TVGN_NEXT);
}
}
解决方案 »
- VC++OpenGL 图形染色染不上去(新手求助)--在线等
- 如何在VC2005中实现Splash Screen加载页面功能?
- jpg图片裁减,复制问题?
- 菜鸟级问题:静态文本控件怎么添加成员变量?
- 重写属性页的OnOk函数
- 截获键盘消息?
- 关于MFC中的类
- =================请问哪里有像金山詞霸的语音朗读引擎的相关资料=========================非常感谢==
- 如何使用vc做一个具有类似word功能ActiveX控件
- 如何在对话框中设置一个计时器?麻烦讲详细点!谢谢~~~~
- 关于GetOverlappedResult函数请教!
- 使用Ftp上传文件时,如何能让程序自动识别应该以那种格式(ASCII或Bin)上传该文件?
{
HTREEITEM hChild;
while(hItem!=NULL)
{
//strNode = GetItemText(hItem);
hChild = GetChildItem(hItem);
if(hChild != NULL)
{
DragItem(hChild);
}
hItem=GetNextItem(hItem, TVGN_NEXT);
}
}我们原来用得。
试试看,如果还不行,请考虑用其他控件或方法解决!
因为我的每个节点上都SetItemData了,都是指向一个new出来的内存块,所以在程序退出时要delete这些内存块。不能遍历跟这有关吗?
{
CString strNode; strNode = GetItemText(hTreeItem);
if(NULL != pTemp)
{
TRACE("Explore node = %s\n", strNode);
}
hFirstChild = GetNextItem(hTreeItem, TVGN_NEXT);
if(hFirstChild!=NULL)
ExploreTreeItem(hFirstChild);
}