⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_61120.htm

📁 vc
💻 HTM
字号:
<p>
序号:61120 发表者:AJ 发表日期:2003-11-17 22:34:29
<br>主题:关于在视图中创建树目录的问题!!!!
<br>内容:void CAddressView::OnInitialUpdate()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CListView::OnInitialUpdate();<BR>&nbsp;&nbsp;&nbsp;&nbsp;CTreeView *pView;<BR>&nbsp;&nbsp;&nbsp;&nbsp;pView-&gt;GetTreeCtrl();<BR>&nbsp;&nbsp;&nbsp;&nbsp;CTreeCtrl &amp;tc = GetTreeCtrl();<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_ImageList.Create(16, 16, ILC_COLORDDB | ILC_MASK, 0, 1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// load images and populate image list -GGH<BR><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;tc.SetImageList(&amp;m_ImageList, TVSIL_NORMAL);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;HTREEITEM hItem;<BR>&nbsp;&nbsp;&nbsp;&nbsp;hItem = tc.InsertItem(&#34;Classical&#34;, 0, 0);<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (hItem)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tc.InsertItem(&#34;J. S. Bach&#34;, 0, 0, hItem);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tc.InsertItem(&#34;W. A. Mozart&#34;, 0, 0, hItem);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tc.InsertItem(&#34;F. Chopin&#34;, 0, 0, hItem);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;// expand<BR>&nbsp;&nbsp;&nbsp;&nbsp;tc.Expand(hItem, TVE_EXPAND);<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;hItem = tc.InsertItem(&#34;Jazz&#34;, 1, 1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (hItem)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tc.InsertItem(&#34;Johnny Hodges&#34;, 1, 1, hItem);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tc.InsertItem(&#34;Charlie Parker&#34;, 1, 1, hItem);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tc.InsertItem(&#34;John Coltrane&#34;, 1, 1, hItem);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;// expand<BR>&nbsp;&nbsp;&nbsp;&nbsp;tc.Expand(hItem, TVE_EXPAND);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: You may populate your ListView with items by directly accessing<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;its list control through a call to GetListCtrl().<BR>}<BR>---出错::<BR>--------------------Configuration: Address - Win32 Debug--------------------<BR>Compiling...<BR>AddressView.cpp<BR>H:\VC\study\Address\AddressView.cpp(68) : error C2065: 'GetTreeCtrl' : undeclared identifier<BR>H:\VC\study\Address\AddressView.cpp(68) : error C2440: 'initializing' : cannot convert from 'int' to 'class CTreeCtrl &amp;'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A reference that is not to 'const' cannot be bound to a non-lvalue<BR>Error executing cl.exe.<BR><BR>Address.exe - 2 error(s), 0 warning(s)<BR>而且树目录前面没有那个加号???GetTreeCtrl();要怎么声明呀???
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:浪际天涯 回复日期:2003-11-18 10:22:54
<br>内容:头文件:#include &lt;afxcmn.h&gt;<BR>CTreeView *pView;<BR>pView-&gt;GetTreeCtrl();//pView此时指针为空,不能调用GetTreeCtrl();<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:AJ 回复日期:2003-11-18 11:34:56
<br>内容:CTreeCtrl &amp;tc = GetTreeCtrl();是怎么加速!!!<BR>GetTreeCtrl();是怎么来的???
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:巴拉克 回复日期:2003-11-18 11:48:36
<br>内容:CTreeView *pView = &amp;GetTreeCtrl();<BR>HTREEITEM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hItem&nbsp;&nbsp;&nbsp;&nbsp;= NULL;<BR>TV_INSERTSTRUCT&nbsp;&nbsp;&nbsp;&nbsp;tvinsert;<BR><BR>tvinsert.hParent&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= NULL;<BR>tvinsert.hInsertAfter&nbsp;&nbsp;&nbsp;&nbsp;= TVI_LAST;<BR>tvinsert.item.mask&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= TVIF_IMAGE | TVIF_SELECTEDIMAGE |<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TVIF_TEXT;<BR>tvinsert.item.hItem&nbsp;&nbsp;&nbsp;&nbsp;= NULL; <BR>tvinsert.item.state&nbsp;&nbsp;&nbsp;&nbsp;= 0;<BR>tvinsert.item.stateMask&nbsp;&nbsp;&nbsp;&nbsp;= 1;<BR>tvinsert.item.cchTextMax&nbsp;&nbsp;&nbsp;&nbsp;= 128;<BR>tvinsert.item.iSelectedImage= 11;<BR>tvinsert.item.cChildren&nbsp;&nbsp;&nbsp;&nbsp;= 0;<BR>tvinsert.item.lParam&nbsp;&nbsp;&nbsp;&nbsp;= 0;<BR><BR>hIndItem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= pView-&gt;InsertItem(&#34;str&#34;,ParentItem);
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:AJ 回复日期:2003-11-19 00:50:14
<br>内容:这是我做的!!!<BR>请问怎么样双击左边的树目录在右边的LIST视图中相应该的显?????????<BR>谢谢!!!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:AJ 回复日期:2003-11-19 00:52:09
<br>内容:这是我做的!!!<BR>请问怎么样双击左边的树目录在右边的LIST视图中相应该的显?????????<BR>谢谢!!! 
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:巴拉克 回复日期:2003-11-19 10:06:26
<br>内容:你要通过双击来选择吗?好像应该GetItemData()一下,取得相应的List中的值
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:浪际天涯 回复日期:2003-11-19 10:11:22
<br>内容:给你我的代码你看看
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:AJ 回复日期:2003-11-19 13:12:28
<br>内容:为什么我用向导新建一个CLeftView <BR>BaseClass是CTreeView会出错!!<BR>--------------------Configuration: Address - Win32 Debug--------------------<BR>Creating Type Library...<BR>Processing H:\VC\study\Address\Address.odl<BR>Address.odl<BR>Processing C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\oaidl.idl<BR>oaidl.idl<BR>Processing C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\objidl.idl<BR>objidl.idl<BR>Processing C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\unknwn.idl<BR>unknwn.idl<BR>Processing C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wtypes.idl<BR>wtypes.idl<BR>Compiling...<BR>View3.cpp<BR>h:\vc\study\address\view3.h(14) : error C2504: 'CTreeView' : base class undefined<BR>H:\VC\study\Address\View3.cpp(17) : error C2440: 'return' : cannot convert from 'class CView3 *' to 'class CObject *'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast<BR>H:\VC\study\Address\View3.cpp(17) : error C2653: 'CTreeView' : is not a class or namespace name<BR>H:\VC\study\Address\View3.cpp(17) : error C2065: 'classCTreeView' : undeclared identifier<BR>H:\VC\study\Address\View3.cpp(28) : error C2653: 'CTreeView' : is not a class or namespace name<BR>H:\VC\study\Address\View3.cpp(39) : error C2065: 'GetDocument' : undeclared identifier<BR>H:\VC\study\Address\View3.cpp(39) : error C2440: 'initializing' : cannot convert from 'int' to 'class CDocument *'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast<BR>H:\VC\study\Address\View3.cpp(49) : error C2653: 'CTreeView' : is not a class or namespace name<BR>H:\VC\study\Address\View3.cpp(54) : error C2653: 'CTreeView' : is not a class or namespace name<BR>Error executing cl.exe.<BR><BR>Address.exe - 9 error(s), 0 warning(s)
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:AJ 回复日期:2003-11-19 13:30:42
<br>内容:我知道了!!!<BR>要在stdafx.h文件上加上#include &lt;afxcview.h&gt;
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:AJ 回复日期:2003-11-19 18:10:53
<br>内容:请问有谁看过我那段代码呀/???<BR>为什么右边的ListView不可以显示左边双击目录树选择的字符串???<BR>就是Joe下面的那的空的???急急呀????<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:AJ 回复日期:2003-11-20 09:17:22
<br>内容:大家来看看吧!!!!很想明白事!!+<BR>是不是在ListView中没有触发消息,所以双击左边的时候是传递了字符串,但在ListView中没有命令使它显示???????<BR>请大侠们看看吧!!!!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:浪际天涯 回复日期:2003-11-20 09:39:01
<br>内容:m_cx是做什么用的?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:浪际天涯 回复日期:2003-11-20 09:41:01
<br>内容:你想完成的是什么功能?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:AJ 回复日期:2003-11-20 11:18:45
<br>内容:m_cx那个没有用的!!!<BR>我就是想双击左边的树在右边ListView显示!!!!<BR>谢谢oxjzhao!!!!!!!!!!!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:浪际天涯 回复日期:2003-11-20 11:25:53
<br>内容:如何去显示呢?是增加到listView中,还是把原来的删除掉,显示点击的?<BR>我调试的时候看到你在InvalidateRect(rcClip,FALSE);句中,rcClip的坐标不对
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:AJ 回复日期:2003-11-20 21:44:40
<br>内容:那个可以不用管他了吧???<BR>就好像我双击Jazz,在右边的列表框里可以显示Jazz呀??????
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:AJ 回复日期:2003-11-25 00:00:21
<br>内容:有谁再帮我看看应该怎么办呀!!????好想死了!!!<BR><BR>VC好难呀!!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -