Jump to content

yet another GUICtrlCreateCombo problem


mrmacadamia
 Share

Recommended Posts

hi i want to create a list of FIXED hdd using GUICtrlCreateCombo.

If i select a harddisk it will show its free space, label and so on.

So far this is what i got. I stuck at how to show different drive with specific data.

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#Include <Array.au3>
#Include <GuiComboBox.au3>


Global Const $CD_VOLUME = DriveGetLabel(@HomeDrive)
Global Const $CD_SERIAL = DriveGetSerial(@HomeDrive)
Global Const $CD_TOTALSPACE = DriveSpaceTotal(@HomeDrive)
Global Const $CD_FREESPACE = DriveSpaceFree(@HomeDrive)
Global Const $CD_SYSTEMTYPE = DriveGetFileSystem(@HomeDrive)
Global Const $CD_STATUS = DriveStatus(@HomeDrive)

_HDD()

Func _HDD()

$MainGUI = GUICreate("HDD", 350, 300, -1, -1)

    $Drives = DriveGetDrive("FIXED")
    $Comb_Data = StringUpper(_ArrayToString($Drives, "|", 1))
    $Combo_Dsel = GUICtrlCreateCombo("", 100, 100, 100, 30, $CBS_DROPDOWNLIST)
    If $Drives[0] Then
        For $i = 0 To $Drives[0]
            _GUICtrlComboBox_AddString($Comb_Data, $Drives[$i])
        Next
    Else
            _GUICtrlComboBox_AddString($Comb_Data, 'None')
            GUICtrlSetState(-1, $GUI_DISABLE)
    EndIf
    GUICtrlSetData($Combo_Dsel, $Comb_Data, StringUpper($Drives[1]))
    _GUICtrlComboBox_SetCurSel($Comb_Data, 0)

    $Round_TOTALSPACE = Round($CD_TOTALSPACE / 1000, 1)
    $Round_FREESPACE = Round($CD_FREESPACE / 1000, 1)
    $Percent_FREESPACE = Round(($CD_FREESPACE / $CD_TOTALSPACE) * 100, 1)
    GUICtrlCreateLabel("FileSystem : ", 110, 160, 70, 14)
    GUICtrlCreateLabel("Capacity : ", 110, 175, 60, 14)
    GUICtrlCreateLabel("Free Space : ", 110, 190, 70, 14)
    GUICtrlCreateLabel("% Free Space : ", 110, 205, 80, 14)

    $filesystem = GUICtrlCreateLabel("", 180, 160, 40, 14)
    GUICtrlSetData($filesystem, $CD_SYSTEMTYPE)

    $capacity = GUICtrlCreateLabel("", 170, 175, 40, 14)
    GUICtrlSetData($capacity, $Round_TOTALSPACE)

    $freespace = GUICtrlCreateLabel("",180, 190, 40, 14)
    GUICtrlSetData($freespace, $Round_FREESPACE)

    $percentfreespace = GUICtrlCreateLabel("", 190, 205, 30, 14)
    GUICtrlSetData($percentfreespace, $Percent_FREESPACE)

    GUISetState()
    While 1
        $nMsg = GUIGetMsg()
        Select
            Case $nMsg = -3
                Exit
            Case $nMsg = $Combo_Dsel
                $cRead = GUICtrlRead($Combo_Dsel)


                ;If $cRead = "C:" Then GUICtrlSetData($capacity, Floor(DriveSpaceTotal($Combo_Dsel) / 1024))
                ;For $i = 1 To $Drives[0]
                ;_GUICtrlComboBox_GetCurSel($Combo_Dsel)
                ;$Drive = GUICtrlRead($Combo_Dsel)
                ;GUICtrlSetData($filesystem, Floor(DriveSpaceTotal($Combo_Dsel) / 1024))
                ; MsgBox(4160, "Information", "Cur Sel: " & _GUICtrlComboBox_GetCurSel($Combo_Dsel))
        EndSelect
    WEnd

EndFunc
Link to comment
Share on other sites

Basically the way I've done it in the past was to check if the selection had changed and then react upon that...

So what you probably want to do is create a zero-based, two dimension array of fixed drives and sizes ($aDriveData) , and populate the combo. Set $sel to be 1 or whatever. Then you want to use something like $cur = _GUICtrlComboBox_GetCurSel to get the selection. If $sel <> $cur then it is different so we want to react. Else we want to sleep or something. If we're reacting we're getting the data in the $aDriveData[$cur][n].

This is persudo, but would be how I would go about doing it.

Cheers,

Brett

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