Jump to content

List of Files in ComboBox?


Knight
 Share

Recommended Posts

Hi,

I am currently having trouble getting a list of all the names of the .INI files in a specified directory to appear in a combo box. I was planning on having each element of the array appear in the combo box, but I can't figure out how to do this. The number of files in the folder that is being searched is unknown, so I want it to show all the ones that exist.

This is what I have so far, I think I might be on the right track but have hit a road block. Any suggestions or alternatives would be greatly appreciated.

; Script generated by GUIBuilder 9.2

#include <GuiConstants.au3>
#include <Array.au3>

; Shows the filenames of all files in the current directory.
$search = FileFindFirstFile(@ScriptDir & "\Profiles\" & "*.ini")  

$ProfileArray = _ArrayCreate($Search)
While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    _ArrayAdd($ProfileArray, $file)
WEnd

; Close the search handle
FileClose($search)



GuiCreate("MyGUI", 400, 62,(@DesktopWidth-400)/2, (@DesktopHeight-62)/2)

$Combo_1 = GuiCtrlCreateCombo("", 50, 20, 130, 21)
GUICtrlSetData(-1, "New Profile","New Profile")
$Load = GuiCtrlCreateButton("Load", 200, 20, 70, 20)
$Save = GuiCtrlCreateButton("Save", 290, 20, 70, 20)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Load
    ;IniReads
    Case $msg = $Save
    ;IniWrites
    Case Else
    ;;;
    EndSelect
WEnd

Cheers,

JKnight

Link to comment
Share on other sites

Please do not use this, it will not work but it is a rough sketch.

$dir = "C:\"

$array = _FileFindAll($dir, "*.*", "")

$Track = 1

For $Track = 1 To $Array[0] Step 1

$x = $x + $parameter

$y = $y + $parameter

GUICtrlCreate....($Array[$track], $x, $y)

Next

Link to comment
Share on other sites

Thanks for the response Smith, but I just figured it out.. Hehe. I asked for help before I tried hard enough.

#include <GuiConstants.au3>
#include <Array.au3>

; Shows the filenames of all files in the current directory.
$search = FileFindFirstFile(@ScriptDir & "\Profiles\" & "*.ini")  

$ProfileArray = _ArrayCreate($Search)
While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    _ArrayAdd($ProfileArray, $file)
WEnd

; Close the search handle
FileClose($search)



GuiCreate("MyGUI", 400, 62,(@DesktopWidth-400)/2, (@DesktopHeight-62)/2)

$Combo_1 = GuiCtrlCreateCombo("New Profile", 50, 20, 130, 21)
$Load = GuiCtrlCreateButton("Load", 200, 20, 70, 20)
$Save = GuiCtrlCreateButton("Save", 290, 20, 70, 20)

For $r = 1 to UBound($ProfileArray, 1) - 1
    GUICtrlSetData($Combo_1, StringTrimRight($ProfileArray[$r], 4), "New Profile")
Next

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Load
    ;IniReads
    Case $msg = $Save
    ;IniWrites
    Case Else
    ;;;
    EndSelect
WEnd
Edited by Knight
Link to comment
Share on other sites

how about something a little bit easier

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$ret,$Btn_Exit,$Status,$msg

GuiCreate("ComboBox Add Dir", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
$ret = _GUICtrlComboAddDir($Combo,"A,H,RO,RW,S,E",@ScriptDir & "\Profiles\" & "*.ini")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
    EndSelect
WEnd
Exit

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

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...