Jump to content

listbox files from open dialouge


 Share

Recommended Posts

#include <GUIConstants.au3>
#include <GuiList.au3>
Global $input
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)
Global $Label9 = GUICtrlCreateLabel("ALabel9", 160, 456, 43, 17)
Global $list1 = GUICtrlCreateList("ll", 16, 304, 129, 201)
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")
Global $Group1 = GUICtrlCreateGroup("Installer Settings:", 8, 8, 329, 273)
Global $Group2 = GUICtrlCreateGroup("Files To Install:", 8, 288, 217, 225)
Global $Group3 = GUICtrlCreateGroup("Drives to Burn to:", 232, 288, 105, 113)
Global $Group4 = GUICtrlCreateGroup("License of Software:", 344, 8, 281, 273)
Global $Group5 = GUICtrlCreateGroup("Welcome Screen Text:", 344, 288, 281, 225)
Global $Button1 = GUICtrlCreateButton("Remove", 152, 336, 57, 25, 0)
Global $Button2 = GUICtrlCreateButton("Browse", 288, 40, 41, 25, 0)
Global $Button3 = GUICtrlCreateButton("Browse", 288, 120, 41, 25, 0)
Global $Button4 = GUICtrlCreateButton("Add", 152, 304, 57, 25, 0)
Global $Button5 = GUICtrlCreateButton("Browse", 288, 160, 41, 25, 0)
Global $Button7 = GUICtrlCreateButton("Preview", 232, 408, 105, 25, 0)
Global $Button8 = GUICtrlCreateButton("Burn Protected Disc", 232, 440, 105, 41, 0)
Global $Button9 = GUICtrlCreateButton("About", 232, 488, 105, 25, 0)
Global $as_drive = DriveGetDrive ("CDROM")
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
            $ret = _GUICtrlListDeleteItem ($list1, 1)
            If ($ret == $LB_ERR) Then
                MsgBox(16, "Error", "You must have at least 1 file to install")
            EndIf
        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
            $var = FileOpenDialog("Title", "", "All (*.*)")
            $var = StringReplace($var, "|", @CRLF)
                If (StringLen($var) > 0) Then
                $ret = _GUICtrlListAddItem ($list1, GUICtrlRead($var))
                If ($ret < 0) Then
                    If ($ret == $LB_ERRSPACE) Then
                        MsgBox(16, "Error", "insufficient space to store the new strings from calling _GUICtrlListAddItem")
                    ElseIf ($ret == $LB_ERR) Then
                        MsgBox(16, "Error", "Unknown error from _GUICtrlListAddItem")
                    EndIf
                EndIf
            EndIf
        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

Thats the code. For some reason, when i try to add files it comes up with an error? What have i done wrong??

Link to comment
Share on other sites

The problem is with the way you've done your _GUICtrlListAddItem.

$var = FileOpenDialog("Title", "", "All (*.*)")
$var = StringReplace($var, "|", @CRLF)
;...
$ret = _GUICtrlListAddItem ($list1, GUICtrlRead($var))oÝ÷ ÛMú½ªÛÉ÷öÖ¢{_Ûæ§xP­®T^iÚÞ¶êç²Ø^éz½ØÁëZ楢¶Ø^v,~ÀuÒ-zh­±¬¬¶­¶¬yÊ'v«jg­z»!¢é]mëaz«¨¶+-®)àþ+hi×jºHmébz÷jÉv®-iº.¶Øb²Þ²¶)j
ºØ^{"²×¶­!jxÁ«'^vȧqëayÚ²Ê^r'âq©eÊëvØ^ÂݲÚâj}ý¶Çuا«b'âÅú+¶¬Â¥u·¦ºé²©eÊȧqèºÇº'+jë°­ m¡ÊÚ²'˲¶âÇ*.®ènW¦ë-±ëmí7êö«jËazÇ¢wij¶¦z׫jwr¢ë!¢é](¡Ûhèjú"vȦV«¦ºé¥j׫µ©jZ(«mëjëh×6_GUICtrlListAddItem ($list1, 0) ; crashes
_GUICtrlListAddItem ($list1, String(0)) ; works
_GUICtrlListAddItem (GUICtrlGetHandle($list1), 0) ; works
Edited by Helge
Link to comment
Share on other sites

  • 2 months later...

To avoid similar problem later take a look at these...

_GUICtrlListAddItem ($list1, 0) ; crashes
_GUICtrlListAddItem ($list1, String(0)) ; works
_GUICtrlListAddItem (GUICtrlGetHandle($list1), 0) ; worksoÝ÷ Ûú®¢×®;¬¶ëëhܸjëh×6#include <A3LListbox.au3>

$hGUI  = GUICreate("List Box", 400, 296)
$hList = _Listbox_Create($hGUI, 2, 2, 396, 294)
GUISetState()

_Listbox_AddString   ($hList, 0)
_Listbox_InsertString($hList, 1, 1)

do
until GUIGetMsg() = $GUI_EVENT_CLOSE
Auto3Lib: A library of over 1200 functions for AutoIt
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...