PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Chris Cullen on April 29, 2005, 11:20:53 AM

Title: Dunno wats happend to FF_Treeview_GetLevel !
Post by: Chris Cullen on April 29, 2005, 11:20:53 AM
Here is a working version!


'-- FF_TreeView_GetLevel -------------------------------------------
'
'   Returns the item's level. The root item is assumed to be at level zero.
'
'   hWndControl: Handle of control (e.g. HWND_FORM1_TREEVIEW1)  
'   hItem:       The handle of the item.
'            
'   Returns:     The item's level in the TreeView.
'
'------------------------------------------------------------------
Function FF_TreeView_GetLevelCJC (ByVal hWndControl As Long, _
                                 ByVal hItem As Long) As Long

   Local hRoot  As Long
   Local mLevel As Long
   
   ' Do a check to ensure that this is actually a window handle
   If IsWindow(hWndControl) Then  
       If hItem <> %Null Then
       
         'Determine the root's handle...
         hRoot = TreeView_GetRoot(hWndControl)
         
         'Walk back up the tree, towards the root...
         While ( hItem <> hRoot ) And ( hItem <> %Null )
     
           Incr mLevel
           hItem = TreeView_GetNextItem( hWndControl, hItem, %TVGN_PARENT )
     
         Wend
       
       End If
       
       Function = mLevel
   
   End If
   
End Function


The old code I was getting does not work, and always returns zero!
:shock:
Title: Dunno wats happend to FF_Treeview_GetLevel !
Post by: TechSupport on April 29, 2005, 04:12:29 PM
Thanks Chris, I'll use the code in the next update.