Labels nachträglich in Tab erstellen.

  • Mal wieder ein Problem :S

    Erstelle in erster Instanz das Tab PC-Info erstellt und möchte in zweiter Instanz dieses mit Labels füllen.
    Konkret geht es um dynamische Labels, welche erstellt und gelöscht werden. (Dynamische Laufwerksabfrage)

    In dem Programmausschnitt erstellt er mir die Labels aber einfach oberhalb der der Tabs.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <ButtonConstants.au3>
    #include <GuiStatusBar.au3>
    #include <TabConstants.au3>
    #include <Array.au3>
    #include <GuiTab.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    $hGui = GUICreate("Test", 754, 420, 173, 131)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    $pgctrl_tabs = GUICtrlCreateTab(8, 8, 732, 352, 0)
    $tab_install = GUICtrlCreateTabItem("Installation")
    $grp_media = GUICtrlCreateGroup("Media", 51, 44, 190, 297)
    GUICtrlSetFont(-1, 8, 400, 0, "Arial")
    $chk_vlc = GUICtrlCreateCheckbox("VLC Player", 91, 69, 97, 20)
    $chk_media = GUICtrlCreateCheckbox("Media Player", 91, 94, 97, 20)
    $chk_radio = GUICtrlCreateCheckbox("Radio.fx", 91, 119, 97, 20)
    $chk_quick = GUICtrlCreateCheckbox("Quicktime", 91, 144, 97, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $tab_pcinf = GUICtrlCreateTabItem("PC-Info")
    GUICtrlCreateTabItem("")
    $cmd_ok = GUICtrlCreateButton("&Ok", 299, 368, 75, 25, $BS_NOTIFY)
    GUICtrlSetOnEvent(-1, "_click")
    $cmd_cancel = GUICtrlCreateButton("&Exit",379, 368, 75, 25, $BS_NOTIFY)
    GUICtrlSetOnEvent(-1, "_Click")
    $hInf = _GUICtrlStatusBar_Create($hGui)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While Sleep(100)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Click()
    Switch @GUI_CtrlId
    Case $cmd_ok
    _drives()
    Case $cmd_cancel
    Exit
    EndSwitch
    EndFunc ;==>_Click

    [/autoit] [autoit][/autoit] [autoit]

    Func _drives()
    Local $bDelete
    Local $c
    Local $aLabels[1] = [$c]
    GUISwitch($pgctrl_tabs, $tab_pcinf) ;==> wird gänzlich ingoriert ?!
    If $bDelete = True Then
    For $i = 0 To UBound($aLabels) - 1
    GUICtrlDelete($aLabels[$i])
    Next
    $aLabels[0] = 0
    EndIf
    Global $aDrives = DriveGetDrive("all")
    $c = $aDrives[0]
    Global $iY
    Global $drfree
    $iY = 42
    Local $i, $sDriveState, $sTmp ,$upper ,$round
    For $i = 1 To $c
    $sDriveState = DriveStatus($aDrives[$i])
    $drfree = DriveSpaceFree($aDrives[$i])
    $roundfree = Round(($drfree / 1024), 2)
    $drtotal = DriveSpaceTotal($aDrives[$i])
    $roundtotal = Round(($drtotal / 1024), 2)
    $drsystem = DriveGetFileSystem($aDrives[$i])
    If $drtotal <> 0 Then
    If $sDriveState <> "UNKNOWN" And $sDriveState <> "INVALID" Then
    $sTmp = DriveGetLabel($aDrives[$i])
    EndIf
    If $sTmp = '' Then
    _CreateLabel(StringUpper($aDrives[$i]), 17, $iY, -1, 27, 0x0200)
    Else
    _CreateLabel(StringUpper($aDrives[$i]) & @CRLF & '(' & $sTmp & ')', 17, $iY, 103, 27, 0)
    EndIf
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    _CreateLabel("Gesamt: ", 175, 12, -1, -1, 0)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    _CreateLabel($roundtotal & " GB", 160, $iY, 70, 27, BitOR(0x01, 0x0200))
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    _CreateLabel("Frei: ", 285, 12, 30, 17, 0)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    _CreateLabel($roundfree & " GB", 260, $iY, 70, 27, BitOR(0x01, 0x0200))
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    _CreateLabel("Dateisystem: ", 355, 12, -1, -1, 0)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    _CreateLabel($drsystem, 370, $iY, -1, 27, BitOR(0x01, 0x0200))
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    $iY = $iY + 40
    EndIf
    Next
    $bDelete = True
    EndFunc ;==>_drives

    [/autoit] [autoit][/autoit] [autoit]

    Func _CreateLabel($sText, $iX, $iY, $iW, $iH, $iSt)
    Local $c
    Local $aLabels[1] = [$c]
    Local $iIndex = $aLabels[0] + 1
    ReDim $aLabels[$iIndex + 1]
    $aLabels[0] = $iIndex
    $aLabels[$iIndex] = GUICtrlCreateLabel($sText, $iX, $iY, $iW, $iH, $iSt)
    GUICtrlSetOnEvent($aLabels[$iIndex], "_drives")
    EndFunc ;==>_CreateLabel

    [/autoit] [autoit][/autoit] [autoit]

    Func _CreateGroup($Text, $X, $Y, $W, $H)
    Local $iI = $aGroups[0] + 1
    MsgBox(0,"$iI",$iI)
    ReDim $aGroups[$iI + 1]
    $aGroups[0] = $iI
    MsgBox(0,"aG",$aGroups[$iI])
    $aGroups[$iI] = GUICtrlCreateGroup($Text, $X, $Y, $W, $H)
    MsgBox(0,"GROUPS",$aGroups[$iI])
    EndFunc ;==> CreateGroup

    [/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    Einmal editiert, zuletzt von ChuckSOG (18. Oktober 2011 um 14:40)

  • [autoit]

    GUISwitch($pgctrl_tabs, $tab_pcinf) -> GUISwitch($hGui, $tab_pcinf)

    [/autoit]

    und ans Ende der Funktion noch:

    [autoit]


    GUICtrlSendMsg($pgctrl_tabs, 0x1330, 1, 0) ; $TCM_SETCURFOCUS = 0x1330
    GUICtrlSendMsg($pgctrl_tabs, 0x1330, 0, 0) ; $TCM_SETCURFOCUS = 0x1330

    [/autoit]

    Wobei die letzten beiden Zeilen bestimmt auch eleganter gehen

  • Funktioniert wunderbar.
    Vielen Dank :)

    Das ganze soll nur aufgerufen werden, wenn ich den Tab aufrufe, aber das werd ich selbst versuchen. :)
    Somit haben sich die letzten beiden Zeilen schon erledigt.

    Chuck