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

📄 19222.html

📁 以电子书的形式收集了VB一些常见问题解决方法,可以很方便的查找自己需要解决的问题.对一些VB初学者很用.
💻 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 21, 1999 at 23:41:29:<p>In Reply to: <a href="19155.html">Re: How to attach the system image list handle to a tree view control ?</a> posted by 吴海文 on September 20, 1999 at 09:01:21:<p>: 对不起!麻烦先进再次解说GetTVItemFromNode,谢谢!<p>Public Function GetTVItemFromNode(hwndTV As Long, _<br>                                                            nod As Node) As Long<br>  Dim nod1 As Node<br>  Dim anSiblingPos() As Integer  ' contains the sibling position of the Node and all it's parents<br>  Dim nLevel As Integer              ' hierarchical level of the Node<br>  Dim hItem As Long<br>  Dim i As Integer<br>  Dim nPos As Integer<p>  Set nod1 = nod<p>  ' Continually work backwards from the current Node to the current Node's<br>  ' first sibling, caching the current Node's sibling position in the one-based<br>  ' array. Then get the first sibling's parent Node and start over. Keep going<br>  ' until the postion of the specified Node's top level parent item is obtained...<br>  Do While (nod1 Is Nothing) = False<br>    nLevel = nLevel + 1<br>    ReDim Preserve anSiblingPos(nLevel)<br>    anSiblingPos(nLevel) = GetNodeSiblingPos(nod1)<br>    Set nod1 = nod1.Parent<br>  Loop<p>  ' Get the hItem of the first item in the treeview<br>  hItem = TreeView_GetRoot(hwndTV)<br>  If hItem Then<p>    ' Now work backwards through the cached Node positions in the array<br>    ' (from the first treeview Node to the specified Node), obtaining the respective<br>    ' item handle for each Node at the cached position. When we get to the<br>    ' specified Node's position (the value of the first element in the array), we<br>    ' got it's hItem...<br>    For i = nLevel To 1 Step -1<br>      nPos = anSiblingPos(i)<br>      <br>      Do While nPos > 1<br>        hItem = TreeView_GetNextSibling(hwndTV, hItem)<br>        nPos = nPos - 1<br>      Loop<br>      <br>      If (i > 1) Then hItem = TreeView_GetChild(hwndTV, hItem)<br>    Next<p>    GetTVItemFromNode = hItem<p>  End If   ' hItem<p>End Function<p><p><br>Public Function TreeView_GetChild(hWnd As Long, hItem As Long) As Long<br>  TreeView_GetChild = TreeView_GetNextItem(hWnd, hItem, TVGN_CHILD)<br>End Function<p>Public Function TreeView_GetNextItem(hWnd As Long, hItem As Long, flag As Long) As Long<br>  TreeView_GetNextItem = SendMessage(hWnd, TVM_GETNEXTITEM, ByVal flag, ByVal hItem)<br>End Function<p>Public Function TreeView_GetNextSibling(hWnd As Long, hItem As Long) As Long<br>  TreeView_GetNextSibling = TreeView_GetNextItem(hWnd, hItem, TVGN_NEXT)<br>End Function<p>Public Function TreeView_GetRoot(hWnd As Long) As Long<br>  TreeView_GetRoot = TreeView_GetNextItem(hWnd, 0, TVGN_ROOT)<br>End Function<p>Public Function GetNodeSiblingPos(nod As Node) As Integer<br>  Dim nod1 As Node<br>  Dim nPos As Integer<br>  <br>  Set nod1 = nod<br>  <br>  ' Keep counting up from one until the Node has no more previous siblings<br>  Do While (nod1 Is Nothing) = False<br>    nPos = nPos + 1<br>    Set nod1 = nod1.Previous<br>  Loop<br>  <br>  GetNodeSiblingPos = nPos<br>  <br>End Function<p><br><br><hr size=7 width=75%><p><a name="followups">Follow Ups:</a><br><ul><!--insert: 19222--></ul><!--end: 19222--><br><hr size=7 width=75%><p></body></html>

⌨️ 快捷键说明

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