Jump to content

Reading list


Recommended Posts

Made an UDF real fast, there may be some errors:

Func _GUICtrlListGetAllText($listbox)
    Dim $listinfo, $returntext
    $listinfo = _GUICtrlListGetInfo($listbox)
    Dim $returntext[$listinfo + 1]
    $returntext[0] = $listinfo
    If $listinfo = 0 Then
        Return $returntext
    EndIf
    For $i = 0 to ($returntext[0] - 1)
        $returntext[$i + 1] = _GUICtrlListGetText($listbox, $i)
    Next
    Return $returntext
EndFunc
Link to comment
Share on other sites

It only return a number. What i'm trying to do is to make a backup program. The user clicks a button, FileOpenDialog() appears. User selects file, clicks open, and then the listbox gets updated with the file specified. That part works fine. But the thing is that the program has to read all files that are in the listbox. And then copy each file separate to a specified destination. What i've got so far:

#include <GUIConstants.au3>

GUICreate("Back It Up",700,250)

$btn1 = GUICtrlCreateButton("Select", 15, 215, 80)
;GUICTRLCreate$btn2 = GUICtrlCreateButton("Selecteer", 220, 33, 80)
$listbox = GUICtrlCreateList("", 10, 10, 150, 210)

$startbackup = GUICtrlCreateButton("Start Backup", 305, 8, 90, 190)



GUISetState ()
While 1
    $msg = GUIGetMsg()
Select
Case $msg = $startbackup
MsgBox(64, "back It Up", "This button will start the backup process")
Case $msg = $btn1

$open1 = FileOpenDialog("bestand Selecteren...", @HomeDrive, "Alle bestanden (*.*)")
GUICtrlSetData($listbox,$open1 & "|")
Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
EndSelect       
WEnd
GUIDelete()

Thanks for your help!

@poisonkiller thanks for making the UDF.

Link to comment
Share on other sites

Hmm... Maybe I should have explained my UDF a little bit more. When you execute this code:

$alltext = _GUICtrlListGetAllText($listbox)

, then my UDF will return an array. $alltext[0] contains the number of lines it found. $alltext[1] contains first item in listbox, $alltext[2] second item in listbox...

Your code(modified):

#include <GUIConstants.au3>
#include <GuiList.au3>

GUICreate("Back It Up",700,250)

$btn1 = GUICtrlCreateButton("Select", 15, 215, 80)
;GUICTRLCreate$btn2 = GUICtrlCreateButton("Selecteer", 220, 33, 80)
$listbox = GUICtrlCreateList("", 10, 10, 150, 210)

$startbackup = GUICtrlCreateButton("Start Backup", 305, 8, 90, 190)



GUISetState ()
While 1
    $msg = GUIGetMsg()
Select
Case $msg = $startbackup
MsgBox(64, "back It Up", "This button will start the backup process")
$alltext = _GUICtrlListGetAllText($listbox)
For $i = 1 to $alltext[0]
    MsgBox(0, "Files in listbox:", $alltext[$i])
Next
Case $msg = $btn1

$open1 = FileOpenDialog("bestand Selecteren...", @HomeDrive, "Alle bestanden (*.*)")
GUICtrlSetData($listbox,$open1 & "|")
Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
EndSelect     
WEnd
GUIDelete()

Func _GUICtrlListGetAllText($listbox)
    Dim $listinfo, $returntext
    $listinfo = _GUICtrlListGetInfo($listbox)
    Dim $returntext[$listinfo + 1]
    $returntext[0] = $listinfo
    If $listinfo = 0 Then
        Return $returntext
    EndIf
    For $i = 0 to ($returntext[0] - 1)
        $returntext[$i + 1] = _GUICtrlListGetText($listbox, $i)
    Next
    Return $returntext
EndFunc
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...