如何动态创建CTreeCtrl并正确显示(在CView里面),谢谢!

huazaimh 2003-12-03 01:07:16
CRect Rect(100,100,500,500);
GetClientRect(&Rect);

DWORD dwStyle = GetWindowLong(ctrTree.m_hWnd,GWL_STYLE);
dwStyle |= TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT;
SetWindowLong(ctrTree.m_hWnd,GWL_STYLE,dwStyle);

ctrTree.Create(dwStyle,Rect,this,IDC_TREE);

m_hRoot->hParent = TVI_ROOT;
m_hRoot = ctrTree.InsertItem("我的电脑",0,0);
// m_hRoot = ctrTree.InsertItem("我dfdf",0,0);
// m_hRoot = ctrTree.InsertItem("eee",0,0);

ctrTree.Expand(m_hRoot,TVE_EXPAND);
ctrTree.ShowWindow(IDC_TREE);
这样写好像不对,就是显示不出来结果,请各位指点一下,谢谢!
...全文
100 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
huazaimh 2003-12-03
  • 打赏
  • 举报
回复
搞定了,呵呵
可能上面的代码少个WS_VISIBLE
huazaimh 2003-12-03
  • 打赏
  • 举报
回复
人气不怎么旺啊
Dijkstra 2003-12-03
  • 打赏
  • 举报
回复
为什么不用CTreeView呢?
huazaimh 2003-12-03
  • 打赏
  • 举报
回复
好的,谢谢!
huazaimh@sina.com
qj7979 2003-12-03
  • 打赏
  • 举报
回复
把你邮箱给我给你发个例子你就清楚了

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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