Jump to content

ALOT of checkboxes


Go to solution Solved by JustSomeone,

Recommended Posts

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 by JustSomeone
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Solution

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 by JustSomeone
Link to comment
Share on other sites

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 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...