lsakizada Posted March 27, 2007 Posted March 27, 2007 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) GUICtrlSetState(-1, $GUI_DEFBUTTON) ;DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $h_GUI, "int", 1000, "long", 0x00040010);explode GUISetState() $x = 1 While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $subs $hCtrl[$x-1]= _GUICtrlTreeViewInsertItem( $treeview,"Sub" & Ubound($hCtrl),$h_root1) Redim $hCtrl[$x + 1] $x+=1 EndSwitch WEnd Be Green Now or Never (BGNN)!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now