manyou07 Posted March 7, 2006 Share Posted March 7, 2006 Okay, I've looked at lots of other posts but nothing seems to work. I have created a program that reads files in a directory, and creates a checkbox for each unique filename. I'm using TreeView with TVS checkboxes, and what I want to do is, once a button is pressed, know which checkboxes are checked. GuiCtrlGetState doesn't work at all, and GuiCtrlRead returns weird values. Is there a different function or am I doing something wrong? Link to comment Share on other sites More sharing options...
CyberSlug Posted March 7, 2006 Share Posted March 7, 2006 In the latest beta there is a library of functions "GuiListView.au3"If you use SciTE, you need to press Alt+F5 to run beta code....#include <GuiConstants.au3> #include <GuiListView.au3> GuiCreate("Example") $listview = GUICtrlCreateListView ("Something",10, 10, 100, 100, -1, BitOr($LVS_EX_CHECKBOXES,$WS_EX_CLIENTEDGE)) Dim $item[4];Let's use an array $item[0] = GUICtrlCreateListViewItem("Zero", $listview) $item[1] = GUICtrlCreateListViewItem("One", $listview) $item[2] = GUICtrlCreateListViewItem("Two", $listview) $item[3] = GUICtrlCreateListViewItem("Three", $listview) $Button = GuiCtrlCreateButton("Detect what's checked", 10, 200, 150, 30) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Button For $i = 0 to 3 If 1 = _GUICtrlListViewGetCheckedState($listview, $i) Then MsgBox(0x1000, "Info", "Item #" & $i & " is checked.") EndIf Next EndSelect WEnd Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
tonedeaf Posted March 7, 2006 Share Posted March 7, 2006 (edited) @Cyberslug manyou07 wants to read the checked state of treeview items. The beta UDFs don't have any functions for reading checked/unchecked state of TreeView items. @manyou07 GuiCtrlRead returns weird valuesThe state of treeview items could be a combined value of many factors. To find out the checked/unchecked state, use: BitAnd(GuiCtrlRead($treeviewitem), 4)which will return 4 if the tree view item is not checked and 0 otherwise. Example: expandcollapse popup#include <GUIConstants.au3> GUICreate("Treeview Demo", 350, 215) $treeview = GUICtrlCreateTreeView(6, 6, 335 , 150, $TVS_CHECKBOXES, $WS_EX_CLIENTEDGE) $generalitem = GUICtrlCreateTreeViewitem("General", $treeview) $displayitem = GUICtrlCreateTreeViewitem("Display", $treeview) $aboutitem = GUICtrlCreateTreeViewitem("About", $generalitem) $compitem = GUICtrlCreateTreeViewitem("Computer", $generalitem) $useritem = GUICtrlCreateTreeViewitem("User", $generalitem) $resitem = GUICtrlCreateTreeViewitem("Resolution", $displayitem) $otheritem = GUICtrlCreateTreeViewitem("Other", $displayitem) GUICtrlSetState($generalitem, BitOr($GUI_EXPAND,$GUI_DEFBUTTON)); Expand the "General"-item and paint in bold GUICtrlSetState($displayitem, BitOr($GUI_EXPAND,$GUI_DEFBUTTON)); Expand the "Display"-item and paint in bold $cmdCheck = GUICtrlCreateButton("Check Tree", 6, 170, 75, 25) GUISetState () While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $cmdCheck MsgBox(0, "", BitAND(GUICtrlRead($generalitem), 4) & @CRLF & _ BitAND(GUICtrlRead($displayitem), 4) & @CRLF & _ BitAND(GUICtrlRead($aboutitem), 4) & @CRLF & _ BitAND(GUICtrlRead($compitem), 4) & @CRLF & _ BitAND(GUICtrlRead($useritem), 4) & @CRLF & _ BitAND(GUICtrlRead($resitem), 4) & @CRLF & _ BitAND(GUICtrlRead($otheritem), 4)) EndSelect WEnd GUIDelete() Exit EDIT: Grammer Edited March 7, 2006 by tonedeaf Link to comment Share on other sites More sharing options...
CyberSlug Posted March 7, 2006 Share Posted March 7, 2006 @Cyberslugmanyou07 wants to read the checked state of treeview items.The beta UDFs don't have any functions for reading checked/unchecked state of TreeView items.My eyes read TreeView, but my brain read ListView for some reason Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Chris2137378 Posted March 7, 2006 Share Posted March 7, 2006 (edited) I too have been struggling with the checkboxes in treeview. Thanks tonedeaf. Edited March 7, 2006 by Chris2137378 Link to comment Share on other sites More sharing options...
manyou07 Posted March 7, 2006 Author Share Posted March 7, 2006 awesome. thanks tonedeaf! out of curiosity, how what do the guictrlread values depend on? it seemed like checking one would affect the read value of another. 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