'treeview expand
'   展开或折叠要显示/隐藏子节点的节点。
'   hWndControl: 控件的句柄 (例如  HWND_FORM1_TREEVIEW1)   
'   hItem:       要展开的项的句柄。
'   nExpand:     %TRUE to expand, %FALSE to collapse.
'   Returns:     %TRUE if expand took place, %FALSE otherwise
Function FF_TreeView_Expand (ByVal hWndControl as HWnd, _
                             ByVal hItem as Handle, _
                             ByVal nExpand as Long) as Long

  
    '检查窗口句柄是否有效
    If IsWindow(hWndControl) Then  

        'Perform the basic action...
        If nExpand Then
          Function = TreeView_Expand( hWndControl, hItem, TVE_EXPAND)
        Else
          Function = TreeView_Expand( hWndControl, hItem, TVE_COLLAPSE)
        End If
      
    End If
    
End Function      

