Jump to content
Sign in to follow this  
basher

Walking a TreeView

Recommended Posts

basher

I hacked up one of the TreeView UDFs to come up with this:

;===============================================================================
;
; Description:      _GUICtrlTreeViewWalkTree
; Parameter(s):     $i_treeview - controlID
; Requirement:          None
; Return Value(s):  None
; User CallTip:     _GUICtrlTreeViewWalkTree($i_treeview) Walk tree view hierarchy (required: <GuiTreeView.au3>)
; Author(s):            basher
; Note(s):          
;
;===============================================================================
Func _GUICtrlTreeViewWalkTree($i_treeview)
    Local $h_item, $hChild, $chk
    
    $h_item = GUICtrlSendMsg($i_treeview, $TVM_GETNEXTITEM, $TVGN_ROOT, 0)
    While $h_item > 0
        $itext = _GUICtrlTreeViewGetText($i_treeview, $h_item)
        $chk = BitAND( _GUICtrlTreeViewGetState($i_treeview, $h_item), 8192)
        ; this is just example code, do what you will on a checked item
        if $chk = 8192 Then MsgBox(0, "Item", $itext & " is checked")

        $hChild = GUICtrlSendMsg($i_treeview, $TVM_GETNEXTITEM, $TVGN_CHILD, $h_item)
        while $hChild > 0
            $itext = _GUICtrlTreeViewGetText($i_treeview, $hChild)
            $chk = BitAND( _GUICtrlTreeViewGetState($i_treeview, $hChild), 8192)
            ; this is just example code, do what you will on a checked item
            if $chk = 8192 Then MsgBox(0, "Item", $itext & " is checked")
            $hChild = GUICtrlSendMsg($i_treeview, $TVM_GETNEXTITEM, $TVGN_NEXT, $hChild)
        WEnd
        $h_item = GUICtrlSendMsg($i_treeview, $TVM_GETNEXTITEM, $TVGN_NEXT, $h_item)
    WEnd
EndFunc   ;==>_GUICtrlTreeViewWalkTree

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×