Alexander Posted March 15, 2005 Share Posted March 15, 2005 Topic says it all, is there a way to read what is selected in a TreeView? Link to comment Share on other sites More sharing options...
Lazycat Posted March 15, 2005 Share Posted March 15, 2005 GUICtrlRead ( $TreeView ) - return control ID of selected item. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
Alexander Posted March 15, 2005 Author Share Posted March 15, 2005 GUICtrlRead ( $TreeView ) - return control ID of selected item.<{POST_SNAPBACK}>is there a way to change that into the actual text? Link to comment Share on other sites More sharing options...
Lazycat Posted March 16, 2005 Share Posted March 16, 2005 No with release version, but this is possible in the current beta version, by reading given treeviewitem with GUICtrlRead in "advanced" mode. Check this here. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
Alexander Posted March 16, 2005 Author Share Posted March 16, 2005 No with release version, but this is possible in the current beta version, by reading given treeviewitem with GUICtrlRead in "advanced" mode. Check this here.<{POST_SNAPBACK}>I have installed the beta version, the help file does not document an advance mode of GUICtrlRead, please clarify. Link to comment Share on other sites More sharing options...
Fur Posted March 16, 2005 Share Posted March 16, 2005 I too am battling this same issue today.. Link to comment Share on other sites More sharing options...
Lazycat Posted March 16, 2005 Share Posted March 16, 2005 Ops, probably JPM forgot include example for advanced mode into beta release. Here is example from previous "autoitspecial" release. expandcollapse popup#include <GUIConstants.au3> Global Const $LVS_EX_CHECKBOXES = 0x00000004 GUICreate("test",500,300) Global $menu1 = GUICtrlCreateMenu("Menu1") Global $menu2 = GUICtrlCreateMenu("Menu2") Global $menuitem1 = GUICtrlCreateMenuItem("Item1",$menu1) Global $menuitem2 = GUICtrlCreateMenuItem("Item2",$menu1) Global $listview = GUICtrlCreateListView("Col1|Col2",10,10,150,100,-1,BitOr($LVS_EX_CHECKBOXES,$WS_EX_CLIENTEDGE)) Global $lvitem1 = GUICtrlCreateListViewItem("Val1|Val2",$listview) Global $lvitem2 = GUICtrlCreateListViewItem("Val3|Val4",$listview) Global $treeview = GUICtrlCreateTreeView(200,10,150,100,BitOr($TVS_CHECKBOXES,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE) Global $tvitem1 = GUICtrlCreateTreeViewItem("Item1",$treeview) Global $tvitem2 = GUICtrlCreateTreeViewItem("Item2",$treeview) Global $buttoncheck = GUICtrlCreateButton("CheckRead",100,250,70,20); Global $buttontree = GUICtrlCreateButton("TreeRead",220,250,70,20); Global $buttonmenu = GUICtrlCreateButton("MenuRead",10,250,70,20); Global $checkbox = GUICtrlCreateCheckbox("Check it",50,150,100,20) Global $modecheck = GUICtrlCreateCheckbox("Advanced Mode",200,150,100,20,$BS_PUSHLIKE); GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $lvitem1 Msgbox(0,"",GUICtrlRead($lvitem1)) Case $msg = $lvitem2 $result = GUICtrlRead($lvitem2,1) If IsArray($result) Then Msgbox(0,"",$result[0] & @LF & $result[1]) EndIf Case $msg = $tvitem1 Msgbox(0,"",GUICtrlRead($tvitem1)) Case $msg = $tvitem2 $result = GUICtrlRead($tvitem2,1) If IsArray($result) Then Msgbox(0,"",$result[0] & @LF & $result[1]) EndIf Case $msg = $buttonmenu CtrlInfo($menu1) Case $msg = $buttoncheck CtrlInfo($checkbox) Case $msg = $buttontree CtrlInfo($treeview) EndSelect WEnd GUIDelete() Exit Func CtrlInfo($ctrlid) Local $ctrlid If GUICtrlRead($modecheck) = $GUI_CHECKED Then $result = GUICtrlRead($ctrlid,1) Else $result = GUICtrlRead($ctrlid) EndIf If IsArray($result) Then Msgbox(0,"Read",$result[0] & @LF & $result[1]) Else Msgbox(0,"Read",$result) EndIf EndFunc Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
spytek_98 Posted March 17, 2005 Share Posted March 17, 2005 Ops, probably JPM forgot include example for advanced mode into beta release. Here is example from previous "autoitspecial" release.expandcollapse popup#include <GUIConstants.au3> Global Const $LVS_EX_CHECKBOXES = 0x00000004 GUICreate("test",500,300) Global $menu1 = GUICtrlCreateMenu("Menu1") Global $menu2 = GUICtrlCreateMenu("Menu2") Global $menuitem1 = GUICtrlCreateMenuItem("Item1",$menu1) Global $menuitem2 = GUICtrlCreateMenuItem("Item2",$menu1) Global $listview = GUICtrlCreateListView("Col1|Col2",10,10,150,100,-1,BitOr($LVS_EX_CHECKBOXES,$WS_EX_CLIENTEDGE)) Global $lvitem1 = GUICtrlCreateListViewItem("Val1|Val2",$listview) Global $lvitem2 = GUICtrlCreateListViewItem("Val3|Val4",$listview) Global $treeview = GUICtrlCreateTreeView(200,10,150,100,BitOr($TVS_CHECKBOXES,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE) Global $tvitem1 = GUICtrlCreateTreeViewItem("Item1",$treeview) Global $tvitem2 = GUICtrlCreateTreeViewItem("Item2",$treeview) Global $buttoncheck = GUICtrlCreateButton("CheckRead",100,250,70,20); Global $buttontree = GUICtrlCreateButton("TreeRead",220,250,70,20); Global $buttonmenu = GUICtrlCreateButton("MenuRead",10,250,70,20); Global $checkbox = GUICtrlCreateCheckbox("Check it",50,150,100,20) Global $modecheck = GUICtrlCreateCheckbox("Advanced Mode",200,150,100,20,$BS_PUSHLIKE); GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $lvitem1 Msgbox(0,"",GUICtrlRead($lvitem1)) Case $msg = $lvitem2 $result = GUICtrlRead($lvitem2,1) If IsArray($result) Then Msgbox(0,"",$result[0] & @LF & $result[1]) EndIf Case $msg = $tvitem1 Msgbox(0,"",GUICtrlRead($tvitem1)) Case $msg = $tvitem2 $result = GUICtrlRead($tvitem2,1) If IsArray($result) Then Msgbox(0,"",$result[0] & @LF & $result[1]) EndIf Case $msg = $buttonmenu CtrlInfo($menu1) Case $msg = $buttoncheck CtrlInfo($checkbox) Case $msg = $buttontree CtrlInfo($treeview) EndSelect WEnd GUIDelete() Exit Func CtrlInfo($ctrlid) Local $ctrlid If GUICtrlRead($modecheck) = $GUI_CHECKED Then $result = GUICtrlRead($ctrlid,1) Else $result = GUICtrlRead($ctrlid) EndIf If IsArray($result) Then Msgbox(0,"Read",$result[0] & @LF & $result[1]) Else Msgbox(0,"Read",$result) EndIf EndFunc<{POST_SNAPBACK}>Cool example I understand hwo to read the checkbox value, but how do set checkbox value for a GUICtrlCreateTreeViewItem? Link to comment Share on other sites More sharing options...
Lazycat Posted March 17, 2005 Share Posted March 17, 2005 I understand hwo to read the checkbox value, but how do set checkbox value for a GUICtrlCreateTreeViewItem?It's pretty easy with GUICtrlSetState() with $GUI_CHECKED/$GUI_UNCHECKED states. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
spytek_98 Posted March 18, 2005 Share Posted March 18, 2005 It's pretty easy with GUICtrlSetState() with $GUI_CHECKED/$GUI_UNCHECKED states.<{POST_SNAPBACK}>GUICtrlSetState() with $GUI_CHECKED didnt work... unless I did something wrong?Here is my example below (based off yours).Thanksexpandcollapse popup#include <GUIConstants.au3> Global Const $LVS_EX_CHECKBOXES = 0x00000004 GUICreate("test",500,300) Global $menu1 = GUICtrlCreateMenu("Menu1") Global $menu2 = GUICtrlCreateMenu("Menu2") Global $menuitem1 = GUICtrlCreateMenuItem("Item1",$menu1) Global $menuitem2 = GUICtrlCreateMenuItem("Item2",$menu1) Global $listview = GUICtrlCreateListView("Col1|Col2",10,10,150,100,-1,BitOr($LVS_EX_CHECKBOXES,$WS_EX_CLIENTEDGE)) Global $lvitem1 = GUICtrlCreateListViewItem("Val1|Val2",$listview) Global $lvitem2 = GUICtrlCreateListViewItem("Val3|Val4",$listview) GUICtrlSetState($lvitem2, $GUI_CHECKED); Does not work for listview. (using AutoIt3.1.0.15J.zip) Global $treeview = GUICtrlCreateTreeView(200,10,150,100,BitOr($TVS_CHECKBOXES,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE) Global $tvitem1 = GUICtrlCreateTreeViewItem("Item1",$treeview) Global $tvitem2 = GUICtrlCreateTreeViewItem("Item2",$treeview) GUICtrlSetState($tvitem2, $GUI_CHECKED); Does work for treeview. Global $buttoncheck = GUICtrlCreateButton("CheckRead",100,250,70,20); Global $buttontree = GUICtrlCreateButton("TreeRead",220,250,70,20); Global $buttonmenu = GUICtrlCreateButton("MenuRead",10,250,70,20); Global $checkbox = GUICtrlCreateCheckbox("Check it",50,150,100,20) Global $modecheck = GUICtrlCreateCheckbox("Advanced Mode",200,150,100,20,$BS_PUSHLIKE); GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $lvitem1 Msgbox(0,"",GUICtrlRead($lvitem1)) Case $msg = $lvitem2 $result = GUICtrlRead($lvitem2,1) If IsArray($result) Then Msgbox(0,"",$result[0] & @LF & $result[1]) EndIf Case $msg = $tvitem1 Msgbox(0,"",GUICtrlRead($tvitem1)) Case $msg = $tvitem2 $result = GUICtrlRead($tvitem2,1) If IsArray($result) Then Msgbox(0,"",$result[0] & @LF & $result[1]) EndIf Case $msg = $buttonmenu CtrlInfo($menu1) Case $msg = $buttoncheck CtrlInfo($checkbox) Case $msg = $buttontree CtrlInfo($treeview) EndSelect WEnd GUIDelete() Exit Func CtrlInfo($ctrlid) Local $ctrlid If GUICtrlRead($modecheck) = $GUI_CHECKED Then $result = GUICtrlRead($ctrlid,1) Else $result = GUICtrlRead($ctrlid) EndIf If IsArray($result) Then Msgbox(0,"Read",$result[0] & @LF & $result[1]) Else Msgbox(0,"Read",$result) EndIf EndFunc Link to comment Share on other sites More sharing options...
Holger Posted March 18, 2005 Share Posted March 18, 2005 (edited) @spytek: not implemented yet -> I knew I did forget something Will try something out now...RegardsHolgerEdit: got it so far - works OK...So I will send it later to jpm Edited March 18, 2005 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
spytek_98 Posted March 18, 2005 Share Posted March 18, 2005 (edited) @spytek: not implemented yet -> I knew I did forget something Will try something out now...RegardsHolgerEdit: got it so far - works OK...So I will send it later to jpm <{POST_SNAPBACK}>Thanks Holger!Look forward in seeing it implemented. Edited March 18, 2005 by spytek_98 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