Jump to content

Combo List


Recommended Posts

Hi All,

I'm trying to build a combo list box that detecs fixed disks on a drop down menu. My current code does not work, any help is much appreciated. I'm still trying other possibilites.

#include <GUIConstants.au3>

Dim $drive1, $drive2, $drive3

$var = DriveGetDrive( "fixed" )

    For $i = 1 to $var[0]
        If $var[$i] = "C:" Then
            $drive1 = "C:\"
        Else
            $drive1 = "C:\ Not Available"
        EndIf
        If $var[$i] = "D:" Then
            $drive2 = "D:\"
        Else
            $drive2 = "D:\ Not Available"
        EndIf       
        If $var[$i] = "E:" Then
            $drive3 = "E:\"
        Else
            $drive3 = "E:\ Not Available"
        EndIf   
    Next

GUICreate("My GUI combo")  ; will create a dialog box that when displayed is centered

GUICtrlCreateCombo ($drive1, 10,10) ; create first item
GUICtrlSetData(-1, $drive2 & "|" & $drive3, $drive1) ; add other item snd set a new default

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Edited by gfunk999
Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

Dim $aFixDrive = DriveGetDrive("FIXED")
Dim $DriveString

For $i = 1 To $aFixDrive[0]
    $DriveString &= $aFixDrive[$i] & "|"
Next

$hGUI = GUICreate("Enum fixed drive`s", 200, 100)

$DriveCombo = GUICtrlCreateCombo("", 10, 40, 180, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, $DriveString, $aFixDrive[1])

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Link to comment
Share on other sites

Rasim thanks for your help. Very nice. Your code works way better than this one; however, I would like to know why I can't read the array columns with this code. Thanks again!

This could work too, I just wrote this, it would work perfect if I could get the $avArray[1][0] to display properly. I get the following error "Array variable has incorrect number of subscripts or subscript dimension range exceeded.:" I don't get it works for another code I have. I get to the array table successfully, and I'm specifying the correct columns???

#include <Array.au3>

Dim $avArray[1]

$var = DriveGetDrive( "all" )

    MsgBox(4096,"", "Found " & $var[0] & " drives")
    For $i = 1 to $var[0]
        MsgBox(4096,"Drive " & $i, $var[$i])
        _ArrayAdd( $avArray, $var[$i])
    Next

_ArrayDisplay( $avArray, "Whole array" )

MsgBox(0, "test", $avArray[1][0])
Edited by gfunk999
Link to comment
Share on other sites

Its because "$avArray[1][0]" has no value. You use a 1 dimensional array "Dim $avArray[1]" So you should use $avArray[1].

#include <Array.au3>

Dim $avArray[1]

$var = DriveGetDrive( "all" )

    MsgBox(4096,"", "Found " & $var[0] & " drives")
    For $i = 1 to $var[0]
        MsgBox(4096,"Drive " & $i, $var[$i])
        _ArrayAdd( $avArray, $var[$i])
    Next

_ArrayDisplay( $avArray, "Whole array" )

MsgBox(0, "test", $avArray[1])
+==================================================================+| The Definition of Madness: Creating a GUI, with GUI automation scripts |+==================================================================+
Link to comment
Share on other sites

Thanks Prophet and for the quick reply. I wasn't aware of dimensional arrays. Is there an easy way to identify the differences? For example the code below I grab a table from a web page and it automatically chose this array -> $aTableData[1][1]

$oIE = _IECreate ("sample.htm",0,1,0,0)
$oTable = _IETableGetCollection ($oIE, 0)
$aTableData = _IETableWriteToArray ($oTable, True)

_ArrayDisplay( $aTableData, "Whole array" )

MsgBox(0, "test", $aTableData[1][1])oÝ÷ Ú«¨µéÚ
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...