Jump to content

Uncheck All Boxes


Recommended Posts

I am trying to make an option where if I check a box, it will check all boxes in the application. Which works. Can I make it so if I uncheck the box after I've checked it, it will uncheck everything?

Case $msg = $all

  If GUICtrlRead($tab) = 0 Then
   GUICtrlSetState($SysInfo, $GUI_CHECKED)
   GUICtrlSetState($Processes, $GUI_CHECKED)
   GUICtrlSetState($Services, $GUI_CHECKED)
   GUICtrlSetState($FileAssoc, $GUI_CHECKED)
   GUICtrlSetState($NTFSInfo, $GUI_CHECKED)
   GUICtrlSetState($DiskMnt, $GUI_CHECKED)
   GUICtrlSetState($Tree, $GUI_CHECKED)
   GUICtrlSetState($STasks, $GUI_CHECKED)
   GUICtrlSetState($IPs, $GUI_CHECKED)
   GUICtrlSetState($CONN, $GUI_CHECKED)
   GUICtrlSetState($Routes, $GUI_CHECKED)
   GUICtrlSetState($ARP, $GUI_CHECKED)
   GUICtrlSetState($DNS, $GUI_CHECKED)
   GUICtrlSetState($SYSTEM, $GUI_CHECKED)
   GUICtrlSetState($SECURITY, $GUI_CHECKED)
   GUICtrlSetState($SAM, $GUI_CHECKED)
   GUICtrlSetState($SOFTWARE, $GUI_CHECKED)
   GUICtrlSetState($HKCU, $GUI_CHECKED)
   GUICtrlSetState($HKU, $GUI_CHECKED)
   GUICtrlSetState($DumpIt, $GUI_CHECKED)
   GUICtrlSetState($MD5, $GUI_CHECKED)
   GUICtrlSetState($SHA1, $GUI_CHECKED)
  Else
   GUICtrlSetState($SysInfo, $GUI_UNCHECKED)
   GUICtrlSetState($Processes, $GUI_UNCHECKED)
   GUICtrlSetState($Services, $GUI_UNCHECKED)
   GUICtrlSetState($FileAssoc, $GUI_UNCHECKED)
   GUICtrlSetState($NTFSInfo, $GUI_UNCHECKED)
   GUICtrlSetState($DiskMnt, $GUI_UNCHECKED)
   GUICtrlSetState($Tree, $GUI_UNCHECKED)
   GUICtrlSetState($STasks, $GUI_UNCHECKED)
   GUICtrlSetState($IPs, $GUI_UNCHECKED)
   GUICtrlSetState($CONN, $GUI_UNCHECKED)
   GUICtrlSetState($Routes, $GUI_UNCHECKED)
   GUICtrlSetState($ARP, $GUI_UNCHECKED)
   GUICtrlSetState($DNS, $GUI_UNCHECKED)
   GUICtrlSetState($SYSTEM, $GUI_UNCHECKED)
   GUICtrlSetState($SECURITY, $GUI_UNCHECKED)
   GUICtrlSetState($SAM, $GUI_UNCHECKED)
   GUICtrlSetState($SOFTWARE, $GUI_UNCHECKED)
   GUICtrlSetState($HKCU, $GUI_UNCHECKED)
   GUICtrlSetState($HKU, $GUI_UNCHECKED)
   GUICtrlSetState($DumpIt, $GUI_UNCHECKED)
   GUICtrlSetState($MD5, $GUI_UNCHECKED)
   GUICtrlSetState($SHA1, $GUI_UNCHECKED)
  EndIf

This is what I tried.... It did not work. Suggestions?

Link to comment
Share on other sites

  • Moderators

SaintedRogue,

This should give you the idea: ;)

#include <GUIConstantsEx.au3>

Global $aCheck[10]

$hGUI = GUICreate("Test", 500, 500)

For $i = 0 To 9
    $aCheck[$i] = GUICtrlCreateCheckbox(" Checkbox " & $i, 10, 10 + (30 * $i), 100, 20)
Next

$hCheck = GUICtrlCreateCheckbox(" Check All ", 10, 450, 100, 20)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hCheck
            Switch GUICtrlRead($hCheck)
                Case 1
                    For $i = 0 To 9
                        GUICtrlSetState($aCheck[$i], $GUI_CHECKED)
                    Next
                    GUICtrlSetData($hCheck, "Uncheck All")
                Case Else
                    For $i = 0 To 9
                        GUICtrlSetState($aCheck[$i], $GUI_UNCHECKED)
                    Next
                    GUICtrlSetData($hCheck, "Check All")
            EndSwitch
    EndSwitch

WEnd

Please ask if you have any questions. :)

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

Any chance of doing it without an array? I have a tabbed GUI. All with several check boxes. I probably did something inefficient and have each check box assigned a different variable.

Like this (but a lot more):

GUICtrlCreateTabItem("Memory")

  $DumpIt = GUICtrlCreateCheckbox("Dump Memory", 30, 45)

GUICtrlCreateTabItem("Preservation")
 
  $MD5 = GUICtrlCreateCheckbox("Hash 'Evidence' with MD5", 30, 45)
  $SHA1 = GUICtrlCreateCheckbox("Hach 'Evidence' with SHA1", 30, 75)

You think reassigning these to something like $CB could be beneficial? Or should I just make a different button that'll unmark them all? I think re-doing the variables may make updating the application easier.

What are your thoughts?

Link to comment
Share on other sites

Could I add something like [$q] to my variables? Making it "$Var[$q]" Then apply

Case 1
                    For $q = 0
                        GUICtrlSetState($q, $GUI_CHECKED)
                    Next
                    GUICtrlSetData($hCheck, "Uncheck All")
                Case Else
                    For $q = 0
                        GUICtrlSetState([$q], $GUI_UNCHECKED)
                    Next
                    GUICtrlSetData($hCheck, "Check All")

Link to comment
Share on other sites

  • Moderators

SaintedRogue,

Next time you create a GUI where you want to do something to lots of controls, start by using arrays to hold the ControlIDs. ;)

In this case you just need to substitute the loop with the list you were using in your first post - something like this:

#include <GUIConstantsEx.au3>

Global $aCheck[10]

$hGUI = GUICreate("Test", 500, 500)

For $i = 0 To 9
    $aCheck[$i] = GUICtrlCreateCheckbox(" Checkbox " & $i, 10, 10 + (30 * $i), 100, 20)
Next

$hCheck = GUICtrlCreateCheckbox(" Check All ", 10, 450, 100, 20)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hCheck
            Switch GUICtrlRead($hCheck)
                Case 1
                    GUICtrlSetState($aCheck[0], $GUI_CHECKED)
                    GUICtrlSetState($aCheck[1], $GUI_CHECKED)
                    GUICtrlSetState($aCheck[2], $GUI_CHECKED)
                    GUICtrlSetState($aCheck[3], $GUI_CHECKED)
                    GUICtrlSetState($aCheck[4], $GUI_CHECKED)
                    GUICtrlSetState($aCheck[5], $GUI_CHECKED)
                    GUICtrlSetState($aCheck[6], $GUI_CHECKED)
                    GUICtrlSetState($aCheck[7], $GUI_CHECKED)
                    GUICtrlSetState($aCheck[8], $GUI_CHECKED)
                    GUICtrlSetState($aCheck[9], $GUI_CHECKED)
                    GUICtrlSetData($hCheck, "Uncheck All")
                Case Else
                    GUICtrlSetState($aCheck[0], $GUI_UNCHECKED)
                    GUICtrlSetState($aCheck[1], $GUI_UNCHECKED)
                    GUICtrlSetState($aCheck[2], $GUI_UNCHECKED)
                    GUICtrlSetState($aCheck[3], $GUI_UNCHECKED)
                    GUICtrlSetState($aCheck[4], $GUI_UNCHECKED)
                    GUICtrlSetState($aCheck[5], $GUI_UNCHECKED)
                    GUICtrlSetState($aCheck[6], $GUI_UNCHECKED)
                    GUICtrlSetState($aCheck[7], $GUI_UNCHECKED)
                    GUICtrlSetState($aCheck[8], $GUI_UNCHECKED)
                    GUICtrlSetState($aCheck[9], $GUI_UNCHECKED)
                    GUICtrlSetData($hCheck, "Check All")
            EndSwitch
    EndSwitch

WEnd

All clear? :)

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

  • Moderators

SaintedRogue,

Glad I could help. :)

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

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