Jump to content

directory list in combo box


TuMiM
 Share

Recommended Posts

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

Opt('MustDeclareVars',1)

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

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

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
$allocated = _GUICtrlComboInitStorage($Combo, 26, 50)
$ret = _GUICtrlComboAddDir($Combo,"drives")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GUICtrlSetData($Status,"Pre-Allocated Memory For: " & $allocated & " Items, Drives Added To ComboBox: " & _GUICtrlComboGetCount($Combo))
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
    EndSelect
WEnd
Exit

just look the function up in the help, you'll see this example, plus the documentation for it.

Edited by gafrost

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

Is there a way to do it without beta? and if not, I can't figure out how to get _GUICtrlComboAddDir to list all the directories in a path. For example, all directories in C:\ without subdirectories.

with beta

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

Opt('MustDeclareVars',1)

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

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

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
$allocated = _GUICtrlComboInitStorage($Combo, 26, 50)
$ret = _GUICtrlComboAddDir($Combo,"A,H,RO,RW,S,E","C:\*.*")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
;GUICtrlSetData($Status,"Pre-Allocated Memory For: " & $allocated & " Items, Drives Added To ComboBox: " & _GUICtrlComboGetCount($Combo))
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
    EndSelect
WEnd
Exit

i'm sure it can be done with-out beta, probably a search function, then set the combobox with the data

Edited by gafrost

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

I'm sorry, I think i was a little vague. I don't want to get the list of files ni a directory, I want to get the list of directories. This function seems to get me the files but not a list of directories.

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

Opt('MustDeclareVars',1)

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

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

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
;$allocated = _GUICtrlComboInitStorage($Combo, 26, 50)
$ret = _GUICtrlComboAddDir($Combo,"D,E","C:\*.*")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
;GUICtrlSetData($Status,"Pre-Allocated Memory For: " & $allocated & " Items, Drives Added To ComboBox: " & _GUICtrlComboGetCount($Combo))
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
    EndSelect
WEnd

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

ok, I know i am doing something wrong but can't figure out how to do this right. First of all why do the directories from _GUICtrlComboAddDir in the combo box have the [ ] around tehm and how do you get rid of that. Also, how can you get the second combo box to use what is chosen from combo1 as it's next path to _GUICtrlComboAddDir?

#include <GUIConstants.au3>
#include <GuiCombo.au3>

;Opt('MustDeclareVars',1)

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

; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 622, 441, 295, 169)
$Input1 = GUICtrlCreateInput("AInput1", 416, 64, 169, 21, -1, $WS_EX_CLIENTEDGE)
$Combo1 = GUICtrlCreateCombo("", 40, 64, 169, 160,$CBS_DROPDOWNLIST)
$ret = _GUICtrlComboAddDir($Combo1,"D,E","C:\*.*")
$ret1 = StringTrimLeft($Combo1, 1)
$ret2 = StringTrimRight($ret1, 1)
$Combo2 = GUICtrlCreateCombo("", 232, 64, 161, 160)
$ret3 = _GUICtrlComboAddDir($Combo2,"D,E", 'C:\ "'& $ret2 &'" \*.*')
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Exit
Link to comment
Share on other sites

ok, I know i am doing something wrong but can't figure out how to do this right. First of all why do the directories from _GUICtrlComboAddDir in the combo box have the [ ] around tehm and how do you get rid of that. Also, how can you get the second combo box to use what is chosen from combo1 as it's next path to _GUICtrlComboAddDir?

If you read the help, you'll see that is says

Includes subdirectories. Subdirectory names are enclosed in square brackets ([ ]).

#include <GUIConstants.au3>
#include <GuiCombo.au3>

;Opt('MustDeclareVars',1)

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

; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 622, 441, 295, 169)
$Input1 = GUICtrlCreateInput("AInput1", 416, 64, 169, 21, -1, $WS_EX_CLIENTEDGE)
$Combo1 = GUICtrlCreateCombo("", 40, 64, 169, 160, $CBS_DROPDOWNLIST)
$ret = _GUICtrlComboAddDir ($Combo1, "D,E", "C:\*.*")
$Combo2 = GUICtrlCreateCombo("", 232, 64, 161, 160)
GUISetState(@SW_SHOW)
$temp_sel = ""
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
      Case Else
         If $temp_sel <> GUICtrlRead($Combo1) Then
            $ret1 = StringTrimLeft(GUICtrlRead($Combo1), 1)
            $ret2 = StringTrimRight($ret1, 1)
            GUICtrlSetData($Combo2, "")
            $ret3 = _GUICtrlComboAddDir ($Combo2, "D,E", "C:\" & $ret2 & "\*.*")
            $temp_sel = GUICtrlRead($Combo1)
         EndIf
   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...