'treeview child count
'   获取子级别数量
'   hWndControl: 控件的句柄 (例如  HWND_FORM1_TREEVIEW1)   
'   hItem:       The handle of the item.
'   Returns:     子的数量
Function FF_TreeView_ChildCount (ByVal hWndControl as HWnd, _
                                 ByVal hItem as Handle) as Long

    Dim hChild as HANDLE
    Dim nCount as Long
  
    '检查窗口句柄是否有效
    If IsWindow(hWndControl) Then  

        hChild = TreeView_GetNextItem( hWndControl, hItem, TVGN_CHILD )
        While hChild <> 0
        
          nCount = nCount + 1
          hChild = TreeView_GetNextItem( hWndControl, hChild, TVGN_NEXT )
        
        Wend
  
        Function = nCount
    End If
    
End Function

