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:
Thanks Chris, I'll use the code in the next update.