Jump to content

Uncheck all


Recommended Posts

Dear all,

I'd like to make an butten to uncheck all the checkboxes.

#include <GUIConstantsEx.au3>
; Aanpassen deze computer op bureaublad
;regwrite("HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}","LocalizedString","REG_EXPAND_SZ","%USERNAME% on %COMPUTERNAME%")

$ininaam = @ScriptDir & "\" & StringTrimRight(@scriptname,4) & ".ini"
$secties = IniReadSectionNames($ininaam)
$aantal = $secties[0]

; Array to hold ControlIDs if the checkboxes
Global $aChecks[$aantal]
;MsgBox(1043, "test",$aantal,"","")
If $aantal <= 5 Then
    $hoogte = 150
Else
    $hoogte = 150 + (($aantal -5)* 20)
Endif
$hGUI = GUICreate("Installatie programmas", 480, $hoogte)

; Create the checkboxes
For $i = 0 To $secties[0] -1
    $clabel = iniread($ininaam,$secties[$i +1], "var2", "Fout")
    $aChecks[$i] = GUICtrlCreateCheckbox($clabel, 10, 10 + (20 * $i), 200, 20)
    GUICtrlSetState ($aChecks[$i], $GUI_CHECKED)
Next


$hButton1 = GUICtrlCreateButton("Installeren", 345, ($hoogte - 35), 60, 25)
$hButton2 = GUICtrlCreateButton("Sluiten", 410, ($hoogte - 35), 60, 25)
$hlabel = GUICtrlCreateLabel("", 240, 60, 160, 40)
$hProgress = GUICtrlCreateProgress(240, 20, 230, 20)
$footer = GUICtrlCreateLabel("", 10, ($hoogte - 25), 330, 20)

GUISetState()
GUICtrlSetData($footer, "Brainwork Systems B.V. | 033 - 247 15 65 | info@brainwork.nl")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton1
            _Installeren()
        Case $hButton2
            Exit
    EndSwitch

WEnd

Func _Installeren()

    ; See how many apps to install - determines how far progress bar moves each time
    Local $iCount = 0
    For $i = $aChecks[0] To $aChecks[$aantal -1]
        If GUICtrlRead($i) = 1 Then $iCount += 1
    Next
    If $iCount = 0 Then Return

    ; This will be increased for each app be install
    $iProgress = 0
    

    ; Run through checkboxes to see which apps to install
    For $i = 0 To $secties[0] -1
        If GUICtrlRead($aChecks[$i]) = 1 Then
            $llabel = iniread($ininaam,$secties[$i +1], "var2", "Fout")
            GUICtrlSetData($hlabel, "Installeren " & $llabel)
            ; Simulate install
            RunWait($ininaam)
            Sleep(1000)
            $iProgress += 100/$iCount
            GUICtrlSetData($hProgress, $iProgress)
        EndIf
    Next

    ; We have finished
    GUICtrlSetData($hlabel, "Installatie compleet")
    GUICtrlSetState($hbutton1, $GUI_DISABLE)

EndFunc

Thank you for the help.

Great,

Aldrinn

Link to comment
Share on other sites

For $i = 0 To $secties[0] -1

$clabel = iniread($ininaam,$secties[$i +1], "var2", "Fout")

$aChecks[$i] = GUICtrlCreateCheckbox($clabel, 10, 10 + (20 * $i), 200, 20)

GUICtrlSetState ($aChecks[$i], $GUI_CHECKED)

Next

Your looping to check them here. Just make a function that unchecks them instead.

For $i = 0 To $secties[0] -1

GUICtrlSetState ($aChecks[$i], $GUI_UNCHECKED)

Next

Link to comment
Share on other sites

Make the button call this function (untested):

Func _Uncheck()
    Local $i
    For $i = 0 To Ubound($aChecks) -1
        GUICtrlSetState ($aChecks[$i], $GUI_UNCHECKED)
    Next
EndFunc

It does about the same thing as line 20-23 in your original script where you set all checkboxes to active.

edit: way too slow :<

Edited by Tvern
Link to comment
Share on other sites

When i uncheck all i can't check 1 checkbox.

I don't understand what you mean with this.

Are you saying you can't check a checkbox after you have used the uncheck all function? In this case you are probably calling the uncheck function over and over. If not try to rephrase that question. You can PM me in dutch for the next 30 min or so if that's easier.

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