P0ZiTR0N Posted December 11, 2009 Posted December 11, 2009 (edited) Here is the codeexpandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Global $i_list, $num, $c1, $c, $tree_list $i_list = _ArrayCreate("") $tree_list = _ArrayCreate("") ; GUI begin $Form = GUICreate("Chekbox checker", 231, 271, 282, 140) $Tree = GUICtrlCreateListView("Items", 8, 8, 129, 240, -1, $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($Tree, 0, $LVSCW_AUTOSIZE_USEHEADER) _ArrayAdd($i_list, "text1") _ArrayAdd($i_list, "text2") _ArrayAdd($i_list, "text3") _ArrayAdd($i_list, "text4") ; reversing, deleting last row with null data _ArrayReverse($i_list) _ArrayPop($i_list) $c=UBound($i_list) ; size of array dimensions $i_list dim $tree_list[$c] ; declaring $tree_list For $c1 = 0 To $c-1 $tree_list[$c1] &= GUICtrlCreateListViewItem(_ArrayPop($i_list), $Tree); moving rows from $ip_list to $tree_list with creating checkboxes Next _ArrayDisplay($tree_list,"") $Start = GUICtrlCreateButton("Start", 144, 8, 81, 25, 0) $Exit = GUICtrlCreateButton("Exit", 144, 40, 81, 25, 0) GUISetState(@SW_SHOW) ; Gui end While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Start For $c=0 to $c1-1 step 1 if BitOR(GUICtrlRead($tree_list[$c], 1), $GUI_CHECKED) = $GUI_CHECKED Then ;checking state of $tree_list ConsoleWrite("Number " & $c & " - Checked. Item data - " & $tree_list[$c] & "" & @CRLF) endif Next Case $Exit Exit EndSwitch WEndThis is the rows in $tree_list nowThis is the rows what I want to put in $tree_listGUI checkbox checking is working normal now. And console writes real checked rows, but the data in array is false,- just numbers. Where could be mistake? Edited December 11, 2009 by P0ZiTR0N
99ojo Posted December 11, 2009 Posted December 11, 2009 (edited) Hi, $tree_list[$c1] &= GUICtrlCreateListViewItem(_ArrayPop($i_list), $Tree); moving rows from $ip_list to $tree_list with creating checkboxes This is not moving the rows from $ip_list to $tree_list. You fill the array with the return value of GUICtrlCreateListViewItem, and this is the id of the control (see helpfile). Also The &= should be replaced by = Return Value Success: Returns the identifier (controlID) of the new control. Failure: Returns 0. You may code like this: For $c1 = 0 To $c-1 If GUICtrlCreateListViewItem($i_list [UBound ($i_list) - 1)], $Tree) Then ; moving rows from $ip_list to $tree_list with creating checkboxes $tree_list[$c1] = _ArrayPop($i_list) EndIf Next ;-)) Stefan Edited December 11, 2009 by 99ojo
P0ZiTR0N Posted December 11, 2009 Author Posted December 11, 2009 Hi, $tree_list[$c1] &= GUICtrlCreateListViewItem(_ArrayPop($i_list), $Tree); moving rows from $ip_list to $tree_list with creating checkboxes This is not moving the rows from $ip_list to $tree_list. You fill the array with the return value of GUICtrlCreateListViewItem, and this is the id of the control (see helpfile). Also The &= should be replaced by = I know this.. this is just a comment. Your code works fine. But it breaks checkboxes checking. Here is the result of checking non-selected cb Number 0 - Checked. Item data - text1 Number 1 - Checked. Item data - text2 Number 2 - Checked. Item data - text3 Number 3 - Checked. Item data - text4Anyway thanx
99ojo Posted December 11, 2009 Posted December 11, 2009 Hi, try version with a 2 d array: expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Global $i_list, $num, $c1, $c, $tree_list $i_list = _ArrayCreate("") $tree_list = _ArrayCreate("") ; GUI begin $Form = GUICreate("Chekbox checker", 231, 271, 282, 140) $Tree = GUICtrlCreateListView("Items", 8, 8, 129, 240, -1, $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($Tree, 0, $LVSCW_AUTOSIZE_USEHEADER) _ArrayAdd($i_list, "text1") _ArrayAdd($i_list, "text2") _ArrayAdd($i_list, "text3") _ArrayAdd($i_list, "text4") ; reversing, deleting last row with null data _ArrayReverse($i_list) _ArrayPop($i_list) $c=UBound($i_list) ; size of array dimensions $i_list dim $tree_list[$c] [2] ; declaring $tree_list For $c1 = 0 To $c-1 $tree_list [$c1] [1] = GUICtrlCreateListViewItem($i_list [UBound ($i_list) - 1], $Tree) ; moving rows from $ip_list to $tree_list with creating checkboxes $tree_list[$c1] [0] = _ArrayPop($i_list) Next _ArrayDisplay($tree_list,"") $Start = GUICtrlCreateButton("Start", 144, 8, 81, 25, 0) $Exit = GUICtrlCreateButton("Exit", 144, 40, 81, 25, 0) GUISetState(@SW_SHOW) ; Gui end While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Start For $c=0 to $c1-1 step 1 if BitOR(GUICtrlRead($tree_list[$c] [1], 1), $GUI_CHECKED) = $GUI_CHECKED Then ;checking state of $tree_list ConsoleWrite("Number " & $c & " - Checked. Item data - " & $tree_list[$c] [0] & "" & @CRLF) endif Next Case $Exit Exit EndSwitch WEnd ;-)) Stefan You may also change ConsoleWrite("Number " & $c & " - Checked. Item data - " & $tree_list[$c] [0] & "" & @CRLF) to ConsoleWrite("ControlID " & $tree_list[$c] [1] & " - Checked. Item data - " & $tree_list[$c] [0] & "" & @CRLF)
P0ZiTR0N Posted December 11, 2009 Author Posted December 11, 2009 O, works fine... Never thought to do this with 2 d array... Thanx for answer
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