' Retrieves the item that is the target of a drag-and-drop operation.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetDropHilight(hwnd As Long) As Long
  TreeView_GetDropHilight = TreeView_GetNextItem(hwnd, 0, TVGN_DROPHILITE)
End Function' Retrieves the topmost or very first item of the tree-view control.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetRoot(hwnd As Long) As Long
  TreeView_GetRoot = TreeView_GetNextItem(hwnd, 0, TVGN_ROOT)
End Function
'
' ======= End TreeView_GetNextItem =============================================
'' ======= Begin TreeView_Select ================================================' Selects the specified tree-view item, scrolls the item into view, or redraws the item
' in the style used to indicate the target of a drag-and-drop operation.
' If hitem is NULL, the selection is removed from the currently selected item, if any.
' Returns TRUE if successful or FALSE otherwise.Public Function TreeView_Select(hwnd As Long, hItem As Long, code As Long) As Boolean
  TreeView_Select = SendMessage(hwnd, TVM_SELECTITEM, ByVal code, ByVal hItem)
End Function' Sets the selection to the specified item.
' Returns TRUE if successful or FALSE otherwise.' If the specified item is already selected, a TVN_SELCHANGING *will not* be generated !!' If the specified item is 0 (indicating to remove selection from any currrently selected item)
' and an item is selected, a TVN_SELCHANGING *will* be generated and the itemNew
' member of NMTREEVIEW will be 0 !!!Public Function TreeView_SelectItem(hwnd As Long, hItem As Long) As Boolean
  TreeView_SelectItem = TreeView_Select(hwnd, hItem, TVGN_CARET)
End Function' Redraws the given item in the style used to indicate the target of a drag and drop operation.
' Returns TRUE if successful or FALSE otherwise.Public Function TreeView_SelectDropTarget(hwnd As Long, hItem As Long) As Boolean
  TreeView_SelectDropTarget = TreeView_Select(hwnd, hItem, TVGN_DROPHILITE)
End Function' Scrolls the tree view vertically so that the given item is the first visible item.
' Returns TRUE if successful or FALSE otherwise.Public Function TreeView_SelectSetFirstVisible(hwnd As Long, hItem As Long) As Boolean
  TreeView_SelectSetFirstVisible = TreeView_Select(hwnd, hItem, TVGN_FIRSTVISIBLE)
End Function
'
' ======= End TreeView_Select ==================================================
'' Retrieves some or all of a tree-view item's attributes.
' Returns TRUE if successful or FALSE otherwise.Public Function TreeView_GetItem(hwnd As Long, pitem As TVITEM) As Boolean
  TreeView_GetItem = SendMessage(hwnd, TVM_GETITEM, 0, pitem)
End Function' Sets some or all of a tree-view item's attributes.
' Old docs say returns zero if successful or - 1 otherwise.
' New docs say returns TRUE if successful, or FALSE otherwisePublic Function TreeView_SetItem(hwnd As Long, pitem As TVITEM) As Boolean
  TreeView_SetItem = SendMessage(hwnd, TVM_SETITEM, 0, pitem)
End Function' Begins in-place editing of the specified item's text, replacing the text of the item with a single-line
' edit control containing the text. This macro implicitly selects and focuses the specified item.
' Returns the handle to the edit control used to edit the item text if successful or NULL otherwise.Public Function TreeView_EditLabel(hwnd As Long, hItem As Long) As Long
  TreeView_EditLabel = SendMessage(hwnd, TVM_EDITLABEL, 0, (hItem))
End Function' Retrieves the handle to the edit control being used to edit a tree-view item's text.
' Returns the handle to the edit control if successful or NULL otherwise.Public Function TreeView_GetEditControl(hwnd As Long) As Long
  TreeView_GetEditControl = SendMessage(hwnd, TVM_GETEDITCONTROL, 0, 0)
End Function' Returns the number of items that are fully visible in the client window of the tree-view control.Public Function TreeView_GetVisibleCount(hwnd As Long) As Long
  TreeView_GetVisibleCount = SendMessage(hwnd, TVM_GETVISIBLECOUNT, 0, 0)
End Function' Determines the location of the specified point relative to the client area of a tree-view control.
' Returns the handle to the tree-view item that occupies the specified point or NULL if no item
' occupies the point.Public Function TreeView_HitTest(hwnd As Long, lpht As TVHITTESTINFO) As Long
  TreeView_HitTest = SendMessage(hwnd, TVM_HITTEST, 0, lpht)
End Function' Creates a dragging bitmap for the specified item in a tree-view control, creates an image list
' for the bitmap, and adds the bitmap to the image list. An application can display the image
' when dragging the item by using the image list functions.
' Returns the handle of the image list to which the dragging bitmap was added if successful or
' NULL otherwise.Public Function TreeView_CreateDragImage(hwnd As Long, hItem As Long) As Long
  TreeView_CreateDragImage = SendMessage(hwnd, TVM_CREATEDRAGIMAGE, 0, ByVal hItem)
End Function' Sorts the child items of the specified parent item in a tree-view control.
' Returns TRUE if successful or FALSE otherwise.
' fRecurse is reserved for future use and must be zero.Public Function TreeView_SortChildren(hwnd As Long, hItem As Long, fRecurse As Boolean) As Boolean
  TreeView_SortChildren = SendMessage(hwnd, TVM_SORTCHILDREN, ByVal fRecurse, ByVal hItem)
End Function' Ensures that a tree-view item is visible, expanding the parent item or scrolling the tree-view
' control, if necessary.
' Returns TRUE if the system scrolled the items in the tree-view control to ensure that the
' specified item is visible. Otherwise, the macro returns FALSE.Public Function TreeView_EnsureVisible(hwnd As Long, hItem As Long) As Boolean
  TreeView_EnsureVisible = SendMessage(hwnd, TVM_ENSUREVISIBLE, 0, ByVal hItem)
End Function

解决方案 »

  1.   

    ' Sorts tree-view items using an application-defined callback function that compares the items.
    ' Returns TRUE if successful or FALSE otherwise.
    ' fRecurse is reserved for future use and must be zero.Public Function TreeView_SortChildrenCB(hwnd As Long, psort As TVSORTCB, fRecurse As Boolean) As Boolean
      TreeView_SortChildrenCB = SendMessage(hwnd, TVM_SORTCHILDRENCB, ByVal fRecurse, psort)
    End Function' Ends the editing of a tree-view item's label.
    ' Returns TRUE if successful or FALSE otherwise.Public Function TreeView_EndEditLabelNow(hwnd As Long, fCancel) As Boolean
      TreeView_EndEditLabelNow = SendMessage(hwnd, TVM_ENDEDITLABELNOW, ByVal fCancel, 0)
    End Function' Retrieves the incremental search string for a tree-view control. The tree-view control uses the
    ' incremental search string to select an item based on characters typed by the user.
    ' Returns the number of characters in the incremental search string.
    ' If the tree-view control is not in incremental search mode, the return value is zero.Public Function TreeView_GetISearchString(hwnd As Long, lpsz As String) As Boolean
      TreeView_GetISearchString = SendMessage(hwnd, TVM_GETISEARCHSTRING, 0, lpsz)
    End Function' ================================================================
    #If (Win32_IE >= &H300) Then
    '
    ' returns (HWND), old?
    Public Function TreeView_SetToolTips(hwnd As Long, hwndTT As Long) As Long   ' IE3
      TreeView_SetToolTips = SendMessage(hwnd, TVM_SETTOOLTIPS, ByVal hwndTT, 0)
    End Function' returns (hWnd)
    Public Function TreeView_GetToolTips(hwnd As Long) As Long   ' IE3
      TreeView_GetToolTips = SendMessage(hwnd, TVM_GETTOOLTIPS, 0, 0)
    End Function
    '
    #End If     ' WIN32_IE >= &H300
    ' ================================================================
    '' ================================================================
    #If (Win32_IE >= &H400) Then
    '
    ' returns (HTREEITEM)
    Public Function TreeView_GetLastVisible(hwnd As Long) As Long   ' IE4
      TreeView_GetLastVisible = TreeView_GetNextItem(hwnd, 0, TVGN_LASTVISIBLE)
    End FunctionPublic Function TreeView_SetInsertMark(hwnd As Long, hItem As Long, fAfter As CBoolean) As Boolean   ' IE4
      TreeView_SetInsertMark = SendMessage(hwnd, TVM_SETINSERTMARK, ByVal CLng(fAfter), ByVal hItem)
    End FunctionPublic Function TreeView_SetUnicodeFormat(hwnd As Long, fUnicode As CBoolean) As Boolean   ' IE4
      TreeView_SetUnicodeFormat = SendMessage(hwnd, TVM_SETUNICODEFORMAT, ByVal CLng(fUnicode), 0)
    End FunctionPublic Function TreeView_GetUnicodeFormat(hwnd As Long) As Boolean   ' IE4
      TreeView_GetUnicodeFormat = SendMessage(hwnd, TVM_GETUNICODEFORMAT, 0, 0)
    End Function' returns (int), old?
    Public Function TreeView_SetItemHeight(hwnd As Long, iHeight As Long) As Long   ' IE4
      TreeView_SetItemHeight = SendMessage(hwnd, TVM_SETITEMHEIGHT, ByVal iHeight, 0)
    End Function' returns (int)
    Public Function TreeView_GetItemHeight(hwnd As Long) As Long   ' IE4
      TreeView_GetItemHeight = SendMessage(hwnd, TVM_GETITEMHEIGHT, 0, 0)
    End Function' returns (COLORREF), old?
    Public Function TreeView_SetBkColor(hwnd As Long, clr As Long) As Long   ' IE4
      TreeView_SetBkColor = SendMessage(hwnd, TVM_SETBKCOLOR, 0, ByVal clr)
    End Function' returns (COLORREF), old?
    Public Function TreeView_SetTextColor(hwnd As Long, clr As Long) As Long   ' IE4
      TreeView_SetTextColor = SendMessage(hwnd, TVM_SETTEXTCOLOR, 0, ByVal clr)
    End Function' returns (COLORREF)
    Public Function TreeView_GetBkColor(hwnd As Long) As Long   ' IE4
      TreeView_GetBkColor = SendMessage(hwnd, TVM_GETBKCOLOR, 0, 0)
    End Function' returns (COLORREF)
    Public Function TreeView_GetTextColor(hwnd As Long) As Long   ' IE4
      TreeView_GetTextColor = SendMessage(hwnd, TVM_GETTEXTCOLOR, 0, 0)
    End Function' returns (UINT), old?
    Public Function TreeView_SetScrollTime(hwnd As Long, uTime As Long) As Long   ' IE4
      TreeView_SetScrollTime = SendMessage(hwnd, TVM_SETSCROLLTIME, ByVal uTime, 0)
    End Function' returns (UINT)
    Public Function TreeView_GetScrollTime(hwnd As Long) As Long   ' IE4
      TreeView_GetScrollTime = SendMessage(hwnd, TVM_GETSCROLLTIME, 0, 0)
    End Function' returns (COLORREF), old?
    Public Function TreeView_SetInsertMarkColor(hwnd As Long, clr As Long) As Long   ' IE4
      TreeView_SetInsertMarkColor = SendMessage(hwnd, TVM_SETINSERTMARKCOLOR, 0, ByVal clr)
    End Function' returns (COLORREF)
    Public Function TreeView_GetInsertMarkColor(hwnd As Long) As Long   ' IE4
      TreeView_GetInsertMarkColor = SendMessage(hwnd, TVM_GETINSERTMARKCOLOR, 0, 0)
    End Function
    '
    #End If  ' (WIN32_IE >= &H400)
    ' ================================================================
      

  2.   

    終于貼完了﹐這是我以前在www.mvps.org找到的﹕
    Listview的API全集(1)-----http://www.csdn.net/expert/topic/640/640091.xml?temp=.8425867
    Listview的API全集(2)-----http://www.csdn.net/expert/topic/640/640101.xml?temp=.6100885
    Treeview的API全集(1)-----http://www.csdn.net/expert/topic/640/640108.xml?temp=.347912
    Treeview的API全集(2)-----http://www.csdn.net/expert/topic/640/640109.xml?temp=.3793146