Sign in to follow this  
Followers 0
BrettF

Add/Remove Files From List Box

6 posts in this topic

What i want to do is have a list box and then 2 buttons. One labled add, the other remove. Then a lable that has the total filesize. How can i code the buttons to add and files and remove the selected ones. Then how can i make the path of all the file written into a text file? And how can i make the label show the total size. (I knows its got something to do with FileGetSize. I'll atach the code here:

Global $Form1 = GUICreate("PDB- Installer Creator", 632, 521, 193, 115)
Global $Pic1 = GUICtrlCreatePic("", 16, 24, 120, 250, BitOR($SS_NOTIFY,$WS_GROUP))
Global $Input1 = GUICtrlCreateInput("1", 168, 81, 113, 21)
Global $Input2 = GUICtrlCreateInput("2", 168, 41, 113, 21)
Global $Input3 = GUICtrlCreateInput('3', 168, 121, 113, 21)
Global $Input4 = GUICtrlCreateInput("4", 384, 305, 233, 21)
Global $Input5 = GUICtrlCreateInput("5", 168, 161, 113, 21)
Global $Input6 = GUICtrlCreateInput("6", 168, 201, 113, 21)
Global $Label1 = GUICtrlCreateLabel("Side Picture (Acutual Size)", 168, 24, 163, 17)
Global $Label2 = GUICtrlCreateLabel("Installer Title", 168, 64, 163, 17)
Global $Label3 = GUICtrlCreateLabel("Installer Icon (32x32)", 168, 104, 163, 17)
Global $Label4 = GUICtrlCreateLabel("Title:", 352, 304, 27, 17)
Global $Label5 = GUICtrlCreateLabel("Text:", 352, 328, 28, 17)
Global $Label6 = GUICtrlCreateLabel("Defult Installation Path", 168, 144, 163, 17)
Global $Label7 = GUICtrlCreateLabel("Start Menu Deafult Name", 168, 184, 163, 17)
Global $Label8 = GUICtrlCreateLabel("ALabel8", 160, 440, 43, 17) ;Label to show total size of files
Global $Label9 = GUICtrlCreateLabel("ALabel9", 160, 456, 43, 17)
Global $List1 = GUICtrlCreateList("ll", 16, 304, 129, 201) ;The list where the files will be shown
Global $DriveCombobox = GUICtrlCreateList("", 240, 304, 89, 84)
Global $Edit1 = GUICtrlCreateEdit("", 352, 24, 265, 241)
GUICtrlSetData(-1, "AEdit1")
Global $Edit2 = GUICtrlCreateEdit("", 352, 344, 265, 161)
GUICtrlSetData(-1, "AEdit2")
$Group1 = GUICtrlCreateGroup("Installer Settings:", 8, 8, 329, 273)
$Group2 = GUICtrlCreateGroup("Files To Install:", 8, 288, 217, 225)
$Group3 = GUICtrlCreateGroup("Drives to Burn to:", 232, 288, 105, 113)
$Group4 = GUICtrlCreateGroup("License of Software:", 344, 8, 281, 273)
$Group5 = GUICtrlCreateGroup("Welcome Screen Text:", 344, 288, 281, 225)
$Button1 = GUICtrlCreateButton("Remove", 152, 336, 57, 25, 0) ; the remove button
$Button2 = GUICtrlCreateButton("Browse", 288, 40, 41, 25, 0)
$Button3 = GUICtrlCreateButton("Browse", 288, 120, 41, 25, 0)
$Button4 = GUICtrlCreateButton("Add", 152, 304, 57, 25, 0) ;the add button
$Button5 = GUICtrlCreateButton("Browse", 288, 160, 41, 25, 0)
$Button7 = GUICtrlCreateButton("Preview", 232, 408, 105, 25, 0)
$Button8 = GUICtrlCreateButton("Burn Protected Disc", 232, 440, 105, 41, 0)
$Button9 = GUICtrlCreateButton("About", 232, 488, 105, 25, 0)

$as_drive = DriveGetDrive ("CDROM");this function returns an array
If Not @error = 1 Then
Local $s_ComboData
For $intcount = 1 to $as_drive[0]
    $s_ComboData &= "|"& StringUpper($as_drive[$intcount])
Next
GUICtrlSetData($DriveCombobox,StringTrimLeft($s_ComboData,1),$as_drive[1])
Else
    Msgbox(0,"ERROR","Could not get system CD and DVD drives.")
    Return 0
EndIf
GUISetState(@SW_SHOW)
While 1
    $Msg = GUIGetMsg()
    Select 
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button1

        Case $msg = $Button2
        $pic = FileOpenDialog ( "Select Side Splash, 120x250:", "", "Images (*.jpg;*.bmp;*.gif)")
        GUICtrlSetImage ($pic1, $pic)
        GUICtrlSetData ( $Input2 ,$pic)
        Case $msg = $Button3
        FileOpenDialog ( "Select Icon, 32x32:", "", "Icons (*.ico)")
        GUICtrlSetData ( $Input2 ,$pic)
        Case $msg = $Button4

        Case $msg = $Button5
        $DefultInstalpth = FileSelectFolder ( "Please Select a Defult Installation Path.", "", "")
        GUICtrlSetData ( $Input5 ,$DefultInstalpth)
    Case $msg = $Button7
        GLOBAL $title = GUICtrlRead ($Input1,0)
        GLOBAL $SidePic = GUICtrlRead ($Input2,0)
        GLOBAL $icon = GUICtrlRead ($Input3,0)
        GLOBAL $wlcmTitle = GUICtrlRead ($Input4,0)
        GLOBAL $DefultInstalpth = GUICtrlRead ($Input5,0)
        GLOBAL $StartMenu = GUICtrlRead ($Input6,0)
        GLOBAL $Filelist = GUICtrlRead ($List1,0)
        GLOBAL $license = GUICtrlRead ($Edit1,0)
        GLOBAL $wlctxt = GUICtrlRead ($Edit2,0)
            Welcomescn ()
        Case $msg = $Button8
            CreateDisc ()
        Case $msg = $Button9

    EndSelect
WEnd

I'm sorry if the GUI is a bit confusing, it is rather large. (in my opinion :P )

Share this post


Link to post
Share on other sites



Look in the help for

_GUICtrlListDeleteItem

_GUICtrlListAddItem and/or _GUICtrlListInsertItem

_GUICtrlListSelectedIndex

for starters


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Hi,

this helps you to avoid double entries in comboboxes. Perhaps you can use it. Johannes

Func _FindDouble($sAString)
    $aString = StringSplit($sAString, '|')
    $sBString = ''
    $iNo = 0
    
    For $i = 1 To $aString[0]
        For $j = 1 To $aString[0]
            $aNo = StringSplit($iNo, '|')
            For $jj = 1 To $aNo[0]
                If $i = $j Then ContinueLoop (2) ; don't compare element with itself
                If $i = Number($aNo[$jj]) Then ContinueLoop (2) ; don't compare with found doubles
            Next
            If $aString[$i] = $aString[$j] Then $iNo = $iNo & '|' & $j ; if it is double, index of double into list
        Next
    Next

    For $i = 1 To $aString[0]
        $iYes = 0
        For $j = 1 To $aNo[0]
            If $i = $aNo[$j] Then $iYes = 1
        Next
        If $iYes = 0 Then $sBString = $sBString & '|' & $aString[$i]
    Next
    $sBString = StringTrimLeft($sBString, 1)
    Return $sBString
EndFunc   ;==>_FindDouble

Johannes LorenzBensheim, Germanyjlorenz1@web.de[post="12602"]Highlightning AutoIt Syntax in Notepad++ - Just copy in your Profile/application data/notepad++[/post]

Share this post


Link to post
Share on other sites

This is the code for the add file to the list box (taken from the helpfile change the input to be a file open dialouge) it always becomes an error. Why?

$input = FileOpenDialog ( "Please select A File to Add", "", "All (*.*)")
If (StringLen(GUICtrlRead($input)) > 0) Then
$ret = _GUICtrlListInsertItem ($list1, GUICtrlRead($input), 2)
If ($ret < 0) Then
MsgBox(16, "Error", "Error (" & $ret & ") from _GUICtrlListInsertItem")
Else
GUICtrlSetData($label8, "Item #: " & $ret)
EndIf
EndIf

Share this post


Link to post
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
Sign in to follow this  
Followers 0