为什么ctreectrl在界面上不能展开??

qass 2005-07-29 03:06:54
BOOL CDepartsel::OnInitDialog()
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here

//load dep info
dep.load_dep();

//add node
m_treeImageList.Create(16,16,FALSE,1,0); //create CImageList
//load ICON resource
HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1));
m_treeImageList.Add(hIcon); //add ICON to CImageList
//associate CImageList with Tree
m_tree.SetImageList(&m_treeImageList, LVSIL_NORMAL);
m_root = m_tree.InsertItem("Department:"); //add node


//call AddtoTree()ㄛadd all info to Tree
AddtoTree(m_root, 0);
m_tree.Expand(m_root, TVE_EXPAND); //expand root

//select root
m_tree.SelectItem(m_root);

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}


void CDepartsel::AddtoTree(HTREEITEM m_node, int depid)
{
//add to treeview by recursion
int i;
HTREEITEM m_child;
//search one to treectrl if satisfy from dep one by one
for(i=0; i<dep.a_depid.GetSize(); i++)
{
//*** search for depid from a_depid
//*** hint the depid is the root node,add it to treectrl as m_child
//*** call SetItemData(),
//*** regard new node as root,recursion call AddtoTree()

if (depid == atoi(dep.a_depid.GetAt(i)))
{
m_child = m_tree.InsertItem(dep.a_depname.GetAt(i), m_node);
m_tree.SetItemData(m_child, atol(dep.a_depid.GetAt(i)));
AddtoTree(m_child, atoi(dep.a_depid.GetAt(i)));
}
}

}



void CDepartsel::OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here

*pResult = 0;
}


是什么错误导致界面上的treeview无法展开呢,编译的时候,没有任何错误啊????
高手救救!!!!!
...全文
97 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qass 2005-07-29
  • 打赏
  • 举报
回复
非常感谢楼上
可是我在双击的情况下一样无法展开啊
healer_kx 2005-07-29
  • 打赏
  • 举报
回复
必然是逻辑问题,你虽然调用了Expand方法。。。但是可能在别的地方的设置,或者是操作又收缩了。

我对树还是有点了解的,市面上有款小软件的树基本是我做的。,
建议你要联系UI的调试,。

64,637

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧