Progress als Slider

  • Guten Morgen,

    ich möchte gerne eine Progress als Slider nutzen, hab mir dann durch die SuFu diesen Code zusammengestrickt.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <Misc.au3>

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

    $hGui = GUICreate("", 400, 100)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
    $hProgress1 = GUICtrlCreateProgress(10, 20, 350, 20)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 7)
    $hProgress2 = GUICtrlCreateProgress(10, 60, 350, 20)
    $hLabel1 = GUICtrlCreateLabel("0%", 365, 22, 35, 20)
    $hLabel2 = GUICtrlCreateLabel("0%", 365, 62, 35, 20)
    GUISetState()

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

    While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $GUI_EVENT_PRIMARYDOWN
    $aInfo = GUIGetCursorInfo($hGui)
    Switch $aInfo[4]
    Case $hProgress1
    While _IsPressed("01")
    $aInfo = GUIGetCursorInfo($hGui)
    $aPos = ControlGetPos($hGui, "", $hProgress1)
    $iPercent = Int(100 / $aPos[2] * ($aInfo[0] - $aPos[0]))
    GUICtrlSetData($hProgress1, $iPercent)
    If $iPercent >= 0 And $iPercent <= 100 Then GUICtrlSetData($hLabel1, $iPercent & "%")
    WEnd
    Case $hProgress2
    While _IsPressed("01")
    $aInfo = GUIGetCursorInfo($hGui)
    $aPos = ControlGetPos($hGui, "", $hProgress2)
    $iPercent = Int(100 / $aPos[2] * ($aInfo[0] - $aPos[0]))
    GUICtrlSetData($hProgress2, $iPercent)
    If $iPercent >= 0 And $iPercent <= 100 Then GUICtrlSetData($hLabel2, $iPercent & "%")
    WEnd
    EndSwitch
    EndSwitch
    WEnd

    [/autoit]

    Nun ist es so. Der obere Progress kommt flüssig hinterher mit der Maus. Nun möchte ich aber den neuen Style nutzen, also den Unteren. Aber dort läuft der Balken der Maus hinterher und es dauert bis er angelangt ist. Was kann ich da machen, dass er genauso schnell ist wie der Obere?

  • Ich hab da auch wenig Hoffnung. Aber es wäre schön wenn. Ansonsten muss ich mir das halt mit GDI machen.;)

  • Das geht ganz einfach:D
    Es gibt nämlich keine Animation, wenn die Progressbar rückwärts läuft, d.h. die Progressbar springt sofort zu dem Wert.
    Du musst also einfach zuerst einen höheren Wert wählen und dann den gewünschten Wert.
    Is halt mehr oder weniger ein Workaround...

    [autoit]

    #include <GUIConstantsEx.au3>
    #include <Misc.au3>

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

    $hGui = GUICreate("", 400, 100)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
    $hProgress1 = GUICtrlCreateProgress(10, 20, 350, 20)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 7)
    $hProgress2 = GUICtrlCreateProgress(10, 60, 350, 20)
    $hLabel1 = GUICtrlCreateLabel("0%", 365, 22, 35, 20)
    $hLabel2 = GUICtrlCreateLabel("0%", 365, 62, 35, 20)
    GUISetState()

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

    While 1
    $nMsg = GUIGetMsg()

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

    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $GUI_EVENT_PRIMARYDOWN
    $aInfo = GUIGetCursorInfo($hGui)
    Switch $aInfo[4]
    Case $hProgress1
    While _IsPressed("01")
    $aInfo = GUIGetCursorInfo($hGui)
    $aPos = ControlGetPos($hGui, "", $hProgress1)
    $iPercent = Int(100 / $aPos[2] * ($aInfo[0] - $aPos[0]))
    GUICtrlSetData($hProgress1, $iPercent)
    If $iPercent >= 0 And $iPercent <= 100 Then GUICtrlSetData($hLabel1, $iPercent & "%")
    WEnd
    Case $hProgress2
    While _IsPressed("01")
    $aInfo = GUIGetCursorInfo($hGui)
    $aPos = ControlGetPos($hGui, "", $hProgress2)
    $iPercent = Int(100 / $aPos[2] * ($aInfo[0] - $aPos[0]))
    GUICtrlSetData($hProgress2, $iPercent+1)
    GUICtrlSetData($hProgress2, $iPercent)
    If $iPercent >= 0 And $iPercent <= 100 Then GUICtrlSetData($hLabel2, $iPercent & "%")
    WEnd
    EndSwitch
    EndSwitch
    WEnd

    [/autoit]
    Zitat

    You just keep on trying 'till you run out of cake. ;)


    [STEAM] Source UDF

    Einmal editiert, zuletzt von K4z (13. März 2012 um 13:19)