有两个问题:1:使用CTreeCtrl函数的时候,Create不是必须的?
MSDN里有这样一句话:“If you specify the tree control in a dialog box template, or if you are using CTreeView, your tree control is created automatically when the dialog box or view is created. If you want to create the tree control as a child window of some other window, use the Create member function.”我现在是把一个CTreeCtrl控件放到一个dialog里面使用的。这个dialog算是一个“dialog box template”吗?我发现如果不使用create函数,而直接用InsertItem是可以的。
HTREEITEM root1 = m_treeids.InsertItem("Dialog1",TVI_ROOT,TVI_LAST);
HTREEITEM root2 = m_treeids.InsertItem("Dialog1",TVI_ROOT,TVI_LAST);
HTREEITEM subnode0 = m_treeids.InsertItem("Pittsburgh",root1,TVI_LAST);
HTREEITEM subnode1 = m_treeids.InsertItem("hello3",root1,TVI_LAST);
m_treeids.Expand(root1,TVE_EXPAND);2: 如果我这样使用Create函数,编译没问题,运行就报错。请问我错在什么地方?
m_treeids.Create((WS_VISIBLE|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS),CRect(0,0,200,200),this,10000);
我想用Create函数是因为我想让父项和子项之间有线相连,这样好看些。就是说想要TVS_HASLINES功能。谢谢!
MSDN里有这样一句话:“If you specify the tree control in a dialog box template, or if you are using CTreeView, your tree control is created automatically when the dialog box or view is created. If you want to create the tree control as a child window of some other window, use the Create member function.”我现在是把一个CTreeCtrl控件放到一个dialog里面使用的。这个dialog算是一个“dialog box template”吗?我发现如果不使用create函数,而直接用InsertItem是可以的。
HTREEITEM root1 = m_treeids.InsertItem("Dialog1",TVI_ROOT,TVI_LAST);
HTREEITEM root2 = m_treeids.InsertItem("Dialog1",TVI_ROOT,TVI_LAST);
HTREEITEM subnode0 = m_treeids.InsertItem("Pittsburgh",root1,TVI_LAST);
HTREEITEM subnode1 = m_treeids.InsertItem("hello3",root1,TVI_LAST);
m_treeids.Expand(root1,TVE_EXPAND);2: 如果我这样使用Create函数,编译没问题,运行就报错。请问我错在什么地方?
m_treeids.Create((WS_VISIBLE|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS),CRect(0,0,200,200),this,10000);
我想用Create函数是因为我想让父项和子项之间有线相连,这样好看些。就是说想要TVS_HASLINES功能。谢谢!
解决方案 »
- 实现类似QQ具有删除功能的下拉列表框
- 图像显示处理-->求速度
- 不懂VC的人提问,关于TCP的数据包分析的,大家请进。
- 向进程注入DLL的问题,可否永久注入
- 字符串输出问题
- 我这里有oracle的oci连接的例子(包括执行存储过程和获得数据集),想交换ado连接oracle的例子。
- 请大侠解释一下这一句的意思,"C:\Program Files\Microsoft Office\Office\winword" AUTOMATION -Embendding
- (100分求帮助)关于一个很简单的播放器问题
- 急救!如何一次打开多个文件,并将其显示出来?
- activex控件和activex容器编程的问题(给我当前的最高分!)
- ADO访问特殊Access数据库时的错误问题
- 如何用vc++ 写一个检测硬盘剩余空间大小的程序
你要想改变style,可以用
BOOL ModifyStyle(
DWORD dwRemove,
DWORD dwAdd,
UINT nFlags = 0
);
CTreeCtrl控件的style. 我是这么用的,结果控件本身毫无变化。ModifyStyle(NULL, TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES | TVS_DISABLEDRAGDROP,0);
你应该调用TreeCtrl的。