Label über Progressbar

  • Hey,

    ich versuche über eine Progressbar einen Label mit dem Fortschritt anzeigen zu lassen.
    Zu Anfang klappt es auch, aber wenn die Progressbar anfängt sich zu bewegen verschwindet der Text sofort.

    [autoit]

    ...
    $gui_progress1 = GUICtrlCreateProgress(0, 540, 800, 30)
    $gui_progress1_status = GUICtrlCreateLabel("", 0, 545, 800, 20, $SS_CENTER)
    ...

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

    GUICtrlSetData($gui_progress1_status, "Dateien werden vorbereitet: " & Round(100/$files_path[0]*$i, 0) & "%")
    GUICtrlSetData($gui_progress1, Round(100/$files_path[0]*$i, 0))

    [/autoit]

    Einmal editiert, zuletzt von MasterOfTime (28. Mai 2012 um 22:10)

  • Versuch mal zuerst den Progress zu aktualisieren und dann das Label. Außerdem heißt das Dateien und nicht Datein.

  • Das geht aber auch so. Dafür braucht man nicht unbedingt GDI. Hab's selber schon hinbekommen.

  • Ohne GDI+ könnte man da so machen:

    Spoiler anzeigen
    [autoit]

    GUICreate("Progress", 520, 60)

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

    $gui_progress1 = GUICtrlCreateProgress(10, 10, 500, 45)
    $gui_progress1_status = GUICtrlCreateLabel("", 150, 25, 200, 15, 0x201, 0x28)

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

    GUISetState()
    AdlibRegister("_Update", 200)

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

    Do
    Until GUIGetMsg() = -3

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

    Func _Update()
    Local Static $i = 0
    Local Static $Up = 1
    If $Up Then
    $i += 5
    Else
    $i -= 5
    EndIf

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

    GUICtrlSetData($gui_progress1, $i)
    GUICtrlSetData($gui_progress1_status, "Dateien werden vorbereitet: " & $i & "%")

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

    If $i = 100 Then $Up = 0
    If $i = 0 Then $Up = 1
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    funkey: Unter Windows 7 flackert Dein Beispiel ziemlich doll. Ich würde da eher den klassischen Stil benutzen:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>

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

    GUICreate("Progress", 520, 60)

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

    $gui_progress1 = GUICtrlCreateProgress(10, 10, 500, 45, $PBS_SMOOTH)
    DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", "", "wstr", ""); Progress im Classic-Style
    GUICtrlSetColor(-1, 0x44FF44) ; Progress Vordergrundfarbe
    GUICtrlSetBkColor(-1, 0xBBBBBB) ; Progress Hintergrundfarbe

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

    $gui_progress1_status = GUICtrlCreateLabel("", 150, 25, 200, 15)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; Label transparent

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

    GUISetState()

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

    Global $iProgress = 0, $iUpDown = 1
    AdlibRegister("_Update", 100)

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

    Do
    Until GUIGetMsg() = -3

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

    Func _Update()
    $iProgress += $iUpDown
    GUICtrlSetData($gui_progress1, $iProgress)
    GUICtrlSetData($gui_progress1_status, "Dateien werden vorbereitet: " & $iProgress & "%")
    If $iProgress >= 100 Or $iProgress <= 0 Then $iUpDown = -$iUpDown
    EndFunc

    [/autoit]
  • Man kann auch eine Child GUI einsetzen.

    [autoit]


    #include <GUIConstantsEx.au3>
    #include <WinAPI.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $hGui = GUICreate("Progress", 520, 60)
    GUISetBkColor(0xF0F0F0, $hGUI)
    $gui_progress1 = GUICtrlCreateProgress(10, 6, 500, 45)
    $hGUI_Child = GUICreate("", 200, 15, 150, 21, $WS_POPUP, $WS_EX_MDICHILD + $WS_EX_LAYERED, $hGui)
    $iColor = 0xAAAAAA
    GUISetBkColor($iColor, $hGUI_Child)
    $gui_progress1_status = GUICtrlCreateLabel("", 0, 0, 200, 15, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "", 5)
    GUISetState(@SW_SHOW, $hGui)
    _WinAPI_SetLayeredWindowAttributes($hGUI_Child, $iColor)
    GUISetState(@SW_SHOW, $hGUI_Child)

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

    AdlibRegister("_Update", 200)

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

    Do
    Until GUIGetMsg() = -3

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

    Func _Update()
    Local Static $i = 0
    Local Static $Up = 1
    If $Up Then
    $i += 5
    Else
    $i -= 5
    EndIf

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

    GUICtrlSetData($gui_progress1, $i)
    GUICtrlSetData($gui_progress1_status, "Dateien werden vorbereitet: " & $i & "%")

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

    If $i = 100 Then $Up = 0
    If $i = 0 Then $Up = 1
    EndFunc

    [/autoit]


    Getestet auf Win7 x64 + Aero.

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯