SaintedRogue Posted January 4, 2012 Posted January 4, 2012 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? expandcollapse popupCase $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?
Moderators Melba23 Posted January 4, 2012 Moderators Posted January 4, 2012 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 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
SaintedRogue Posted January 4, 2012 Author Posted January 4, 2012 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?
SaintedRogue Posted January 4, 2012 Author Posted January 4, 2012 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")
Moderators Melba23 Posted January 4, 2012 Moderators Posted January 4, 2012 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: expandcollapse popup#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 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
SaintedRogue Posted January 4, 2012 Author Posted January 4, 2012 Thanks! You've been great! I'm still learning, this is only the second GUI I've made and this one include a TON more than my prior one.
Moderators Melba23 Posted January 4, 2012 Moderators Posted January 4, 2012 SaintedRogue, Glad I could help. 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
SaintedRogue Posted January 4, 2012 Author Posted January 4, 2012 Excellent! Got it working now. It would have been a lot easier to make an array, but I didn't realize I could 'til it was too late.
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