Jump to content

Dynamically Created Check Boxes


Recommended Posts

Edit.. I've solved it I think, I have put my modified code below if anyone is interested in knowing what I did

This script goes through a folder and gets a list of file extensions and puts them into $aArray

Then I want to have a Gui with check boxes next to the file extensions, and be able to get a list of all the file extensions checked.

I don't know how I would get the data out

could someone point me in the right direction. Also I would like to be able to have a check all check none checkbox.

$Run1 = 1
SearchExt ("D:\Kiosk_")
FileListGui("D:\Kiosk_")

Func SearchExt($current)

    
    If $Run1 = 0 Then
    ;Dim $aArray[1]
        $source = $current
        If StringRight($current, 1) = '\' Then $current = StringTrimRight($current, 1)
        $Run1 = 1
    EndIf
    
    Local $search = FileFindFirstFile($current & "\*.*")
    While 1
        Dim $file = FileFindNextFile($search)
        If @error Or StringLen($file) < 1 Then ExitLoop
        If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
            $exists = 0
            $Split = StringSplit ($file, ".")
            
            For $i = 1 to Ubound ($aArray) - 1
                If $Split[Ubound ($split) - 1] = $aArray[$i] then 
                    $exists = 1 
                    Exitloop
                EndIf
            Next
                if $exists = 0 then 
                    ReDim $aArray[UBound($aArray) + 1];resize array
                    $aArray[UBound($aArray) - 1] = $Split[Ubound ($split) - 1]
                EndIf
        EndIf
        If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then SearchExt($current & "\" & $file)
    WEnd
    FileClose($search)

    $Run1 = 0
;FileListGui()
EndFunc  ;==>ProgressCopy


Func FileListGui($Wdir)
    #include <GuiConstants.au3>
Dim $checked[1]
$li = GuiCreate("File Extensions", 485, 485,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Label_2 = GuiCtrlCreateLabel($Wdir, 10, 10, 160, 20)
$All = GUICtrlCreateCheckbox ("All/None", 20,40)
For $i = 1 to Ubound ($aArray)-1
    
    if $i <  21 then 
        ReDim $Checked[UBound($Checked) + 1];resize array
                    $Checked[UBound($Checked) - 1] = GUICtrlCreateCheckbox ( $aArray[$i], 20, 40 + ($i * 20) )
    elseif $i < 41 then 
        ReDim $Checked[UBound($Checked) + 1];resize array
                    $Checked[UBound($Checked) - 1] = GUICtrlCreateCheckbox ( $aArray[$i], 120, 40 + ( ($i - 20)  * 20) )    
    elseif $i < 61 then 
        ReDim $Checked[UBound($Checked) + 1];resize array
                    $Checked[UBound($Checked) - 1] = GUICtrlCreateCheckbox ( $aArray[$i], 220, 40 + ( ($i - 40)  * 20) )
    elseif $i < 81 then 
        ReDim $Checked[UBound($Checked) + 1];resize array
                    $Checked[UBound($Checked) - 1] = GUICtrlCreateCheckbox ( $aArray[$i], 320, 40 + ( ($i - 60)  * 20) )
        Endif
Next    
GuiSetState()

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $All
        If BitAnd(GUICtrlRead($All),$GUI_CHECKED) then
            For $i = 1 to Ubound ($Checked) - 1
            GUICtrlSetState( $Checked[$i], $GUI_CHECKED )
        Next
        Elseif BitAnd(GUICtrlRead($All),$GUI_UNCHECKED) then
            For $i = 1 to Ubound ($Checked) - 1
            GUICtrlSetState( $Checked[$i], $GUI_UNCHECKED )
            Next
            Endif
    Case Else
    ;;;
    EndSelect
WEnd

For $i = 1 to Ubound ($Checked) - 1
If BitAnd(GUICtrlRead($Checked[$i]),$GUI_CHECKED) then MsGbox (0,"", $aArray[$i])
Next
GuiDelete ($li)
EndFunc
Edited by ChrisL
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...