Jump to content

Need help with checkbox (check/uncheck all)


Go to solution Solved by Nine,

Recommended Posts

Posted
I finalized the script for my needs from Andreik, everything is fine, but there is still one task that I cannot cope with and for this I need your help.
I need to enable the checkbox (check uncheck all). How can i engage checkbox to check all from list. Can you help me please?

 

#RequireAdmin
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <File.au3>
#Include <Array.au3>
Global $sSourceDir = @ScriptDir 
Global $sDestinationDir
Global $hGUI, $cList, $cAppData, $cCommonFiles, $cExtract
Global $aFile = _FileListToArray($sSourceDir, Default, $FLTA_FOLDERS, False)
If Not IsArray($aFile) Then Exit
$hGUI = GUICreate('MOD1', 330, 365)
GUISetBkColor(0x00c6e2ff)
GUISetFont(9, 200)
$surt = @ScriptDir & "\logo.bmp"
$bud = GUICtrlCreatePic($surt,5,5,130,65)
$Label = GUICtrlCreateLabel('', 2, 78, 326, 0, $SS_ETCHEDHORZ)
$cList = GUICtrlCreateListView("Select the apps you wish to install", 10, 90, 310, 240, $WS_BORDER, $LVS_EX_FULLROWSELECT + $LVS_EX_CHECKBOXES)
GUICtrlSetBkColor(-1, 0xfaebd7)
GUICtrlSetFont(-1, 9, 300, 1, "Tahoma")
GUICtrlCreateGroup(' Select Destination', 140, 5, 185, 65)
GUICtrlSetFont(-1, 8, 300, 2, "Tahoma")
$cAppData = GUICtrlCreateRadio('Install to Roaming DIR', 148, 25, 170, 20)
$cCommonFiles = GUICtrlCreateRadio('Install to CommonFiles DIR', 148, 45, 170, 20)
GUICtrlCreateGroup('', -99, -99, 1, 1)
$cExtract = GUICtrlCreateButton('Start', 125, 335, 80, 20)
$xCheck = GUICtrlCreateCheckbox("Check All", 215, 335, -1, -1)
_GUICtrlListView_BeginUpdate($cList)
For $Index = 1 To $aFile[0]
    If StringLeft($aFile[$Index], 1) = '_' Then ContinueLoop
    GUICtrlCreateListViewItem($aFile[$Index], $cList)
Next
_GUICtrlListView_EndUpdate($cList)
_GUICtrlListView_SetColumnWidth($cList, 0, 292)
GUISetState(@SW_SHOW, $hGUI)
$FileList =_FileListToArray(@ScriptDir & "\", "*", 2)
If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
$HaBudbu = GUICtrlCreateLabel('Found ' & $FileList[0] & ' Folders', 15, 340, -1, -1)
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetFont(-1, 8, 300, 3, "Tahoma")
While True
    Switch GUIGetMsg()
        Case $cExtract
            If GUICtrlRead($cAppData) = $GUI_CHECKED Then $sDestinationDir =  @AppDataDir & '\ChessBase\Engines.UCI'
            If GUICtrlRead($cCommonFiles) = $GUI_CHECKED Then $sDestinationDir =  @CommonFilesDir & '\ChessBase\Engines.UCI'
            If $sDestinationDir Then
            For $Index = 0 To _GUICtrlListView_GetItemCount($cList) - 1
            If _GUICtrlListView_GetItemChecked($cList, $Index) Then
            SplashTextOn('', 'Installing: ' & _GUICtrlListView_GetItemText($cList, $Index), 330,100,-1,-1,1,"Tahoma", 10, 400)
            DirCopy($sSourceDir & '\' & _GUICtrlListView_GetItemText($cList, $Index), $sDestinationDir, 1)
            DirCopy($sSourceDir & "\_x", $sDestinationDir, 1)                 
            Sleep(300)
            ;SplashOff()
            EndIf
            Next
            SplashTextOn('', 'COMPLETED!', 330,100,-1,-1,1,"Tahoma", 10, 400)
            Sleep(2000)
            SplashOff()
                Exit
            Else
            SplashTextOn('Error', 'Please select the Destination' & _GUICtrlListView_GetItemText($cList, $Index), 330,100,-1,-1,1,"Tahoma", 10, 400)
                Sleep(2000)
                SplashOff()
            EndIf
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

 

  • Solution
Posted (edited)

Here.  You should also consider to toggle check all to uncheck all.

Case $xCheck
        For $i = 0 To _GUICtrlListView_GetItemCount($cList) - 1
          _GUICtrlListView_SetItemChecked($cList, $i, GUICtrlRead($xCheck) = $GUI_CHECKED)
        Next

 

Edited by Nine
Posted
9 minutes ago, Nine said:

Here.  You should also consider to toggle check all to uncheck all.

Case $xCheck
        For $i = 0 To _GUICtrlListView_GetItemCount($cList) - 1
          _GUICtrlListView_SetItemChecked($cList, $i, GUICtrlRead($xCheck) = $GUI_CHECKED)
        Next

 

Yes it works!

It  was so easy but with my knowlege it's so difficult.

Thank you very much

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
  • Recently Browsing   0 members

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