Prgressbar mit for schleife synchronisieren.

  • ich habe eine for schleife, welche sich durch die zuvor eingelesene datei definiert. somit ist der to wert immer unterschiedlich.

    ich gehe mal von 15349 als to wert aus.
    wie kann ich dem progressbar klar machen wann das nächste prozent dazu kommt?

    15349 = 100%
    153,49 = 1%

    das ist mir klar, aber wie bekomme ich das sinnvoll in die for next schleife um den progressbar mit brauchbaren daten zu füttern?

    ich stehe da gerade massiv auf dem schlauch.

    I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.

    Einmal editiert, zuletzt von Maximus1 (16. Mai 2013 um 12:48)

  • Spoiler anzeigen
    [autoit]

    Global $iMax = 15349, $rPercent

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

    ProgressOn("Test", "Dies ist ein Test", "0.0 %")
    For $i = 0 To $iMax
    $rPercent = ($i * 100) / $iMax
    ProgressSet($rPercent, Round($rPercent, 1) & " %")
    _HighPrecisionSleep(1)
    Next
    Sleep(500)
    ProgressOff()

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

    ; #FUNCTION#;===============================================================================
    ;
    ; Name...........: _HighPrecisionSleep()
    ; Description ...: Sleeps down to 0.1 microseconds
    ; Syntax.........: _HighPrecisionSleep( $iMicroSeconds, $hDll=False)
    ; Parameters ....: $iMicroSeconds - Amount of microseconds to sleep
    ; $hDll - Can be supplied so the UDF doesn't have to re-open the dll all the time.
    ; Return values .: None
    ; Author ........: Andreas Karlsson (monoceres)
    ; Modified.......:
    ; Remarks .......: Even though this has high precision you need to take into consideration that it will take some time for autoit to call the function.
    ; Related .......:
    ; Link ..........;
    ; Example .......; No
    ;
    ;;==========================================================================================
    Func _HighPrecisionSleep($iMicroSeconds,$hDll=False)
    Local $hStruct, $bLoaded
    If Not $hDll Then
    $hDll=DllOpen("ntdll.dll")
    $bLoaded=True
    EndIf
    $hStruct=DllStructCreate("int64 time;")
    DllStructSetData($hStruct,"time",-1*($iMicroSeconds*10))
    DllCall($hDll,"dword","ZwDelayExecution","int",0,"ptr",DllStructGetPtr($hStruct))
    If $bLoaded Then DllClose($hDll)
    EndFunc

    [/autoit]

    Das _HighPrecisionSleep ist nur drin, damit man überhaupt einen Balken sieht.

  • vielleicht so:

    [autoit]

    For $i = 0 To 15349
    GUICtrlSetData($h_progress, ($i / 15349) * 100)
    Next

    [/autoit]


    Perfekt!!!
    wusste doch das es was einfaches war, bin echt nur nicht drauf gekommen.

    @m-obi: auch dir danke, aber das ist wohl zuviel des guten bei einem solch kleinen projekt wie meinem.

    I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.

  • Zuviel des Guten??? Da ist doch nur noch das "andere" Sleep drin. Schon logisch, dass du das wahrscheinlich nicht brauchst. Und außerdem wusste ich nicht welche Progressbar du meinst, die Stand-Alone oder die in einer GUI. Es geht ja nur um die Rechnung, die man in der Schule lernt.