Das Problem an sich ist, dass die Labels mit einem Array erstellt werden.
Wird die Funktion erneut ausgeführt, werden diese zwar gelöscht, aber das Array hat mehr Plätze, womit es auf Dauer zum Speicherfresser wird, ich finde leider den Fehler nicht.
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include "GUICtrlOnHover.au3"
#include <ButtonConstants.au3>
#include <Array.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]$hGui = GUICreate("Test", 754, 420, 173, 131)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$cmd_ok = GUICtrlCreateButton("&Ok",299, 368, 75, 25, $BS_NOTIFY)
GUICtrlSetOnEvent(-1, "_drives")
Global $c
Global $aLabels[1] = [$c]
Global $bDelete
Func _drives ()
If $bDelete = True Then
For $i = 0 To UBound($aLabels) -1
GuiCtrlDelete($aLabels[$i])
MsgBox(0,"",$aLabels[$i])
Next
EndIf
Global $aDrives = DriveGetDrive("all")
$c = $aDrives[0]
MsgBox(0,"",$c)
Global $iX
Global $drfree
$iX = 17
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]) & @CRLF, $iX, 40, 51, 35, 0x01)
Else
_CreateLabel(StringUpper($aDrives[$i]) & @CRLF & '(' & $sTmp & ')', $iX, 40, 51, 35, 0x01)
EndIf
GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFFFFFF)
_CreateLabel("Gesamt: ", $iX+8, 84, 49, 17, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
_CreateLabel($roundtotal & " GB", $iX+8, 112, -1, -1, 0)
GUICtrlSetBkColor(-1, 0xFFFFFF)
_CreateLabel("Frei: ", $iX+8, 139, 30, 17, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
_CreateLabel($roundfree & " GB", $iX+8, 166, -1, -1, 0)
GUICtrlSetBkColor(-1, 0xFFFFFF)
_CreateLabel("Dateisystem: ", $iX+8, 197, -1, -1, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
_CreateLabel($drsystem, $iX+8, 224, -1, -1, 0)
$iX = $iX +91
EndIf
Next
$bDelete = True
EndFunc
GUISetState()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]While Sleep(100)
WEnd
Func _CreateLabel($sText, $iX, $iY, $iW, $iH, $iSt)
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
Func _Exit()
Exit
EndFunc ;==>_Exit
Zur Info:
Die erste MsgBox zeigt die Anzahl der erkannten Laufwerke. Alle Laufwerke mit der Gesamtgröße von 0 werden übersprungen.
Sobald die Funktion mittels des Buttons erneut ausgeführt wird, zeigt die zweite MsgBox die Gesamtzahl des Arrays angezeigt und dann alle nach einander gelöscht. Jedoch wird am eine eine höhere Zahl gezeigt.
Chuck