JustSomeone Posted November 8, 2013 Share Posted November 8, 2013 (edited) Hello, Can someone give me advice for GUI checkboxes. I have simple GUI with a ton of checkboxes on it ( total of 52, soon to be more). How can i control most of them, without having to type tons of this GUICtrlSetState($Checkboxxx, $GUI_CHECKED) GUICtrlSetState($Checkboxxx, $GUI_SHOW) Or GUICtrlRead($Checkbox37) = 4 Then do stuff repeat the procedure for next checkbox . I don't believe it is needed to post the entire code, since its plain gui with 52 checkboxes and 2 buttons on it ~ Logic behind this : if i uncheck checkbox 1 the gui need to uncheck and hide checkboxes from 2 to 30 or something, but if checkbox 1 is checked, and i click button 1 to do some stuff according to the checkboxes. EDIT: I whant to be able to uncheck some checkboxes manually and do other things according to the checked / unchecked status of each checkbox The coding of the program is not a problem, all i need is any way to avoid typing walls of text with `almost` same lines. Maybe some array? can gui controls be there? Edited November 8, 2013 by JustSomeone Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 8, 2013 Moderators Share Posted November 8, 2013 JustSomeone,Arrays would seem to be the way to go. You can store the checkbox controlIDs in an array and then very quickly loop through it to deal with a given range of them. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Solution JustSomeone Posted November 8, 2013 Author Solution Share Posted November 8, 2013 (edited) Thanks, i will try this out. Will post feedback if i get stuck somewhere EDIT Dear Melba23 I love you :~ Func x32show() If GUICtrlRead($Checkbox[38]) = 4 Then For $n = UBound($Checkbox) = 1 to 33 step 1 GUICtrlSetState($n, $GUI_UNCHECKED) GUICtrlSetState($n, $GUI_HIDE) Next Elseif GUICtrlRead($Checkbox[38]) = 1 Then For $n = UBound($Checkbox) = 1 to 33 step 1 GUICtrlSetState($n, $GUI_CHECKED) GUICtrlSetState($n, $GUI_SHOW) Next EndIf EndFunc works like a charm Edited November 8, 2013 by JustSomeone Link to comment Share on other sites More sharing options...
jdelaney Posted November 8, 2013 Share Posted November 8, 2013 (edited) Use an enumerated list: Enum, to define the subscripts of the array...It will be easier to see what the "38" represents, since it's a variable...then you can use those for your loops as well, and if you happen to ever add in another checkbox between "1" and "33", you won't have to dig in and change your code...also, you would not have to update your hard coded "38" in the If statements. Edited November 8, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. 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