📄 19076.html
字号:
<html> <head> <title>Re: How to attach the system image list handle to a tree view control ?</title> </head> <body bgcolor="#FFFFFF" vlink="#808080"> <center> <h1>Re: How to attach the system image list handle to a tree view control ?</h1> </center><hr size=7 width=75%><hr size=7 width=75%><p>Posted by Sun Jack on September 18, 1999 at 00:48:56:<p>In Reply to: <a href="18987.html">Re: How to attach the system image list handle to a tree view control ?</a> posted by 吴海文 on September 16, 1999 at 10:23:15:<p>: : : 我在VB表单上,放置一个TreeView控制项(名称为treFolder),在程式中使用如下的叙述取得system imagelist handle。<br>: : : himlSmall = SHGetFileInfo("C:\", 0, sfi, Len(sfi), SHGFI_SYSICONINDEX Or SHGFI_SMALLICON)<br>: : : 但要如何指定给treFolder.ImageList?<p>: : SendMessage hWnd, TVM_SETIMAGELIST, ByVal iImage, ByVal himl<p>: 谢谢你的解答,但这个方法我己经试过,仍不能正确运作,在执行加入节点时会出现Run-time error '35613' ImageList must be initialized befor it can be used.<br>: 我的程式码如下:<p>....................<p><br>你使用 System ImageList 给 TreeView 使用,在 Nodes.Add 时就不能指定 ImageList 的 icon index,<br>你需要使用 TVITEM struct 来指定 index,你的程式码,<br>Set nodX = treFolder.Nodes.Add(, , , sRootName, sfi.iIcon)<br>需改成<p>Dim tvi As TVITEM<br>tvi.hItem = GetTVItemFromNode(treFolder.hWnd, treFolder.Nodes(1))<br>tvi.iImage = sfi.iIcon<br>tvi.iSelectedImage = sfi.iIcon<br>tvi.mask = TVIF_HANDLE Or TVIF_IMAGE Or TVIF_SELECTEDIMAGE<br>tvi.stateMask = TVIS_OVERLAYMASK<br>SendMessage treFolder.hWnd, TVM_SETITEM, 0&, tvi<p><br>这边有个奇怪的现像,就是在 Design Time 时,就先放入一个TreeView Control 时,执行上面的程式,并不会把 icon 显示出来,需在Form Load 时,先执行 <br>me.show<br>me.fresh<br>这样,icon 才会显示出来,如果是Run Time 时才建立TreeView Control(使用 CreateWindowEx),则无此现像<br><br><hr size=7 width=75%><p><a name="followups">Follow Ups:</a><br><ul><!--insert: 19076--><!--top: 19155--><li><a href="19155.html">Re: How to attach the system image list handle to a tree view control ?</a> <b>吴海文</b> <i>09:01:21 9/20/99</i>(<!--responses: 19155-->1)<ul><!--insert: 19155--><!--top: 19222--><li><a href="19222.html">Re: How to attach the system image list handle to a tree view control ?</a> <b>Sun Jack</b> <i>23:41:29 9/21/99</i>(<!--responses: 19222-->0)<ul><!--insert: 19222--></ul><!--end: 19222--></ul><!--end: 19155--><!--top: 19154--><li><a href="19154.html">Re: How to attach the system image list handle to a tree view control ?</a> <b>吴海文</b> <i>08:57:41 9/20/99</i>(<!--responses: 19154-->0)<ul><!--insert: 19154--></ul><!--end: 19154--></ul><!--end: 19076--><br><hr size=7 width=75%><p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -