Tiger Posted October 14, 2007 Share Posted October 14, 2007 (edited) How can i get the name of the treeview item. Then I click on the treeviewitem 2.1 then i will show the name in a msgbox Opt("GUIOnEventMode", 1) #include <GUIConstants.au3> Dim $treeviewitem[3] GUICreate("", 400, 400) GUISetOnEvent($GUI_EVENT_CLOSE, "_close") $treeview = GUICtrlCreateTreeView(20, 20, 200, 200) $treeviewitem[1] = GUICtrlCreateTreeViewItem("Tree 1", $treeview) $treeviewitem[2] = GUICtrlCreateTreeViewItem("Tree 2", $treeview) GUISetState(@SW_SHOW) GUICtrlCreateTreeViewItem("Treeitem 1.1", $treeviewitem[1]) GUICtrlCreateTreeViewItem("Treeitem 1.2", $treeviewitem[1]) GUICtrlCreateTreeViewItem("Treeitem 2.1", $treeviewitem[2]) GUICtrlCreateTreeViewItem("Treeitem 2.2", $treeviewitem[2]) Func _close() Exit EndFunc While 1 sleep(500) WEnd Edited October 14, 2007 by Tiger My UDFs:- _RegEnumKey Link to comment Share on other sites More sharing options...
Zedna Posted October 14, 2007 Share Posted October 14, 2007 (edited) Use latest beta 3.2.9.3 #include <GUIConstants.au3> Dim $treeviewitem[3] $gui = GUICreate("", 400, 400) $treeview = GUICtrlCreateTreeView(20, 20, 200, 200) $treeviewitem[1] = GUICtrlCreateTreeViewItem("Tree 1", $treeview) $treeviewitem[2] = GUICtrlCreateTreeViewItem("Tree 2", $treeview) GUICtrlCreateTreeViewItem("Treeitem 1.1", $treeviewitem[1]) GUICtrlCreateTreeViewItem("Treeitem 1.2", $treeviewitem[1]) GUICtrlCreateTreeViewItem("Treeitem 2.1", $treeviewitem[2]) GUICtrlCreateTreeViewItem("Treeitem 2.2", $treeviewitem[2]) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $treeview $item = ControlTreeView($gui, "", $treeview, "GetSelected") $text = ControlTreeView($gui, "", $treeview, "GetText", $item) MsgBox(0, 'Text',$text) EndSelect WEnd Edited October 14, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Tiger Posted October 15, 2007 Author Share Posted October 15, 2007 The script is very good. but i will have to get the name of the item, like Treeitem 1.1 The I click on the item "Treeitem 1.1" then show the name in a messagebox My UDFs:- _RegEnumKey Link to comment Share on other sites More sharing options...
Madza91 Posted October 15, 2007 Share Posted October 15, 2007 Hi guys is possible somehow to add icon on treeview like in listview? [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
GaryFrost Posted October 16, 2007 Share Posted October 16, 2007 Hi guys is possible somehow to add icon on treeview like in listview?_GUICtrlTreeView_InsertItem_GUICtrlTreeView_SetIcon_GUICtrlTreeView_Add_GUICtrlTreeView_AddChild _GUICtrlTreeView_AddChildFirst_GUICtrlTreeView_AddFirstand probably more in the beta SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
smashly Posted October 16, 2007 Share Posted October 16, 2007 (edited) Looks like it's time for me to move onto beta autoit from what Gary posted above No api calls or beta or anything fancy .. but icons and retrieve the text of the selected item in the crude example below..expandcollapse popup#include <GUIConstants.au3> #include <File.au3> Opt("GUIOnEventMode", 1) $Gui = GUICreate("TreeView", 400, 400) $treeview = GUICtrlCreateTreeView(20, 20, 200, 200) Root($treeview) GUISetOnEvent($GUI_EVENT_CLOSE, "_close") GUISetState(@SW_SHOW) While 1 Sleep(500) WEnd Func TellMe() MsgBox(0,'', GUICtrlRead(@GUI_CtrlId, 1)) EndFunc Func Root($tvcID) Dim $DGD = DriveGetDrive("ALL") For $i = 1 To $DGD[0] GUICtrlCreateTreeViewItem("(" & $DGD[$i] & ")", $tvcID) GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlSetOnEvent(-1, "TellMe") GUICtrlSetImage(-1, "shell32.dll", FindIcon($DGD[$i]), 2) GUICtrlSetImage(-1, "shell32.dll", FindIcon($DGD[$i]), 4) If $DGD[$i] = @HomeDrive Then $FL2A = _FileListToArray($DGD[$i], "*", 2) For $j = 1 To $FL2A[0] GUICtrlCreateTreeViewItem($FL2A[$j], GUICtrlRead($tvcID)) GUICtrlSetImage(-1, "shell32.dll", -5, 2) GUICtrlSetImage(-1, "shell32.dll", -4, 4) GUICtrlSetOnEvent(-1, "TellMe") Next EndIf Next EndFunc Func FindIcon($dI) Local $DGT = DriveGetType($dI) Switch $DGT Case "Removable" If $dI = "a:" Or $dI = "b:" Then Return -7 Else Return -8 EndIf Case "Fixed" Return -9 Case "Network" If DriveMapGet($dI) <> "" Then Return -10 Else Return -11 EndIf Case "CDROM" Return -12 Case "RAMDisk" Return -13 Case "Unknown" Return -54 EndSwitch EndFunc Func _close() Exit EndFunc cheers Edited October 16, 2007 by smashly Link to comment Share on other sites More sharing options...
Madza91 Posted October 16, 2007 Share Posted October 16, 2007 ty man [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
Tiger Posted October 20, 2007 Author Share Posted October 20, 2007 Can everybody help me by the problem in post 1 My UDFs:- _RegEnumKey Link to comment Share on other sites More sharing options...
GaryFrost Posted October 20, 2007 Share Posted October 20, 2007 Can everybody help me by the problem in post 1When you say "name", do you mean the text of the item? if not the item doesn't have a name, it has an id. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
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