lrstndm Posted December 27, 2012 Share Posted December 27, 2012 (edited) #include <WindowsConstants.au3> #include <GuiTreeView.au3> Local $checked Local $array[4] $array[1] = "Test 1" $array[2] = "Test 2" $array[3] = "Test 3" Opt("GUIOnEventMode", 1) $form = GUICreate("Checked", 602, 432, 192, 124) $treeview = GUICtrlCreateTreeView(35, 200, 184, 80, BitOR($GUI_SS_DEFAULT_TREEVIEW,$TVS_CHECKBOXES) + BitNOT($TVS_HASLINES), $WS_EX_CLIENTEDGE) For $t = 1 To UBound($array) -1 Step + 1 GUICtrlCreateTreeViewItem($array[$t], $treeview) Next $button = GUICtrlCreateButton("CHECK", 5,5,100,50) GUICtrlSetOnEvent($button, "Go") GUISetState(@SW_SHOW, $form) While 1 Sleep(10) WEnd Func Go() $count = _GUICtrlTreeView_GetCount($treeview) For $x = 1 To $count Step + 1 $checked = _GUICtrlTreeView_GetChecked($treeview, $array[$x]) ; $checked is set to True if item is checked and to False if item is not checked MsgBox(0, '', $array[$x] & " checked is: " & $checked) Next EndFunc Why isn't my code working? I want the variable '$checked' to be updated but as I see it is not doing that. What am I doing wrong? Edited December 27, 2012 by lrstndm Link to comment Share on other sites More sharing options...
Developers Jos Posted December 27, 2012 Developers Share Posted December 27, 2012 You haven't saved the Handle of the TreeView items and are querying the status with the value. Untested: Local $checked Local $Array[4] Local $hArray[4] $Array[1] = "Test 1" $Array[2] = "Test 2" $Array[3] = "Test 3" Opt("GUIOnEventMode", 1) $form = GUICreate("Checked", 602, 432, 192, 124) $treeview = GUICtrlCreateTreeView(35, 200, 184, 80, BitOR($GUI_SS_DEFAULT_TREEVIEW, $TVS_CHECKBOXES) + BitNOT($TVS_HASLINES), $WS_EX_CLIENTEDGE) For $t = 1 To UBound($Array) - 1 Step +1 $hArray[$x] = GUICtrlCreateTreeViewItem($Array[$t], $treeview) Next $button = GUICtrlCreateButton("CHECK", 5, 5, 100, 50) GUICtrlSetOnEvent($button, "Go") GUISetState(@SW_SHOW, $form) While 1 Sleep(10) WEnd Func Go() $count = _GUICtrlTreeView_GetCount($treeview) For $x = 1 To $count Step +1 $checked = _GUICtrlTreeView_GetChecked($treeview, $hArray[$x]) ; $checked is set to True if item is checked and to False if item is not checked MsgBox(0, '', $Array[$x] & " checked is: " & $checked) Next EndFunc ;==>Go SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
lrstndm Posted December 27, 2012 Author Share Posted December 27, 2012 Thanks a lot little bit changes to your code, but then it works. 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