Jump to content
Sign in to follow this  

Getting Dynamic GUiTree Item handle

Recommended Posts


How do I get a selected tree item handle when clicking on it with the mouse.

Does AutoIt can perform this action?

I know there are functions to get the parent handle but what about the selected item?

Does GUICtrlGetHandle function can help (I have not seen a solution yet..)

Here is a simple example for what I need.

Do right click on Main folder to add sub item...

#include <GuiTreeView.au3>
#include <Array.au3>
Opt("MustDeclareVars", 1)

Dim $h_GUI, $Msg, $treeview
Dim $h_root1, $h_tmp ,$var1
Dim $n_btn_getstate
dim $buttoncontext ,$subs ,$temp2 
$h_GUI = GUICreate("Tree View Test", 500, 400)
Dim $hCtrl[1]
Dim $x =1
$treeview = GUICtrlCreateTreeView(10, 10, 200, 380, -1, $WS_EX_CLIENTEDGE)
$h_root1 = GUICtrlCreateTreeViewItem( "Main",$treeview)
GUICtrlSetImage(-1, "shell32.dll", 4, 2)
$var1 = GUICtrlCreateContextMenu($h_root1)
$subs = GUICtrlCreateMenuitem(" Add Sub Folder Under Main " , $var1)
;DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $h_GUI, "int", 1000, "long", 0x00040010);explode
$x = 1
While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
        Case $subs
            $hCtrl[$x-1]=  _GUICtrlTreeViewInsertItem( $treeview,"Sub" & Ubound($hCtrl),$h_root1)
            Redim $hCtrl[$x + 1]

Be Green Now or Never (BGNN)!

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