Jump to content

Progress Bar Scaleing


Recommended Posts

I have a progress bar eg.

$Progressbar = GUICtrlCreateProgress(7, 72, 432, 12)

<-----------------------------------------------------------------------------------------> Say 100 points long

Now what is happening when I use the progress bar its filling the bar past what I can see for example it finds new records and goes to 177 but I can only see to 100. I would like it to load the 177 so it ends at the 100 point..

Hopefully that makes sense to someone muttley

I don't want to change the display SIZE of the bar.

Thanks

Link to comment
Share on other sites

I have a progress bar eg.

$Progressbar = GUICtrlCreateProgress(7, 72, 432, 12)

<-----------------------------------------------------------------------------------------> Say 100 points long

Now what is happening when I use the progress bar its filling the bar past what I can see for example it finds new records and goes to 177 but I can only see to 100. I would like it to load the 177 so it ends at the 100 point..

Hopefully that makes sense to someone muttley

I don't want to change the display SIZE of the bar.

Thanks

To find the percentage of each increment, just divide 100 (which is the total length of the progress bar) by the total (177 records). Then after each record is processed, add 100/177 to the current progress.
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

To find the percentage of each increment, just divide 100 (which is the total length of the progress bar) by the total (177 records). Then after each record is processed, add 100/177 to the current progress.

Falls over shaking... Umm This is what I have

$Progressbar = GUICtrlCreateProgress(7, 72, 432, 12)

For $iIndex = 1 To $oRS.RecordCount

GUICtrlSetData($Progressbar, $iIndex)

$oRS.MoveNext

Next

Where abouts to I include that calculation.. ?

Link to comment
Share on other sites

Falls over shaking... Umm This is what I have

$Progressbar = GUICtrlCreateProgress(7, 72, 432, 12)

For $iIndex = 1 To $oRS.RecordCount

GUICtrlSetData($Progressbar, $iIndex)

$oRS.MoveNext

Next

Where abouts to I include that calculation.. ?

$Progressbar = GUICtrlCreateProgress(7, 72, 432, 12)
$progress = 0

For $iIndex = 1 To $oRS.RecordCount
GUICtrlSetData($Progressbar, $progress)
$progress += 100/$oRS.RecordCount
$oRS.MoveNext
Next
Edited by Airwolf
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

Why is the $progress += 100/177 after it sets it ???

To add another 100/177 to the $progress variable so that the next time the For loop kicks off and the progress bar is updated, it will display the proper percentage. Without the $progress += 100/177 line, the progress bar would be updated to 0% every time.
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

To add another 100/177 to the $progress variable so that the next time the For loop kicks off and the progress bar is updated, it will display the proper percentage. Without the $progress += 100/177 line, the progress bar would be updated to 0% every time.

Ahhh.. Man that makes way more sense.. Thanks for the GREAT HELP...

P.S. IT worked perfect...

Link to comment
Share on other sites

Just for reference, here's what I did on mine.

Func _cList()
    WinActivate($title)
    
    Dim $aList[1][5]
    
    $i_path_1 = FileOpenDialog("Load Forms", @DesktopDir & "\", "MS Excel Files (*.xl*;*.xls)", 4)
    $i_path_2 = FileOpenDialog("Create List or Add to a List", @DesktopDir & "\", "MS Excel Files (*.xl*;*.xls)")
    
    $aFiles = StringSplit($i_path_1, '|')
    
    ;_ArrayDisplay ($aFiles, "$aFiles") ; for debug
    
    $mousePos = MouseGetPos()
    
    _MouseTrap($mousePos[0], $mousePos[1], $mousePos[0], $mousePos[1])
    
    $prog_gui = GuiCreate("Please wait", 500, 70, -1, $guiloc_y-100)
    $prog_bar1 = GUICtrlCreateProgress ($offset_1, 5, 475, 10, $PBS_SMOOTH)
    $prog_bar2 = GUICtrlCreateProgress ($offset_1, 20, 475, 10, $PBS_SMOOTH)
    $prog_label = GUICtrlCreateLabel ("", $offset_1, 35, 475, 25)
    GUISetState (@SW_SHOW, $prog_gui)
    $prog_perc1 = 0
    $prog_perc2 = 0
    
    For $ia = 0 To Ubound($aFiles) - 3
        $cOrig = 26 ;26 or 28
        
        GUICtrlSetData ($prog_label, "Reading..." & @CRLF & $aFiles[1] & "\" & $aFiles[$ia+2])
        $aList[$ia][0] = _ExcelReadCell($rExcel, "C5")              ; description
        $aList[$ia][1] = _ExcelReadCell($rExcel, "C7")              ; manufacturer
        $aList[$ia][2] = _ExcelReadCell($rExcel, "C9")              ; mfg partnumber
        $aList[$ia][3] = _ExcelReadCell($rExcel, "C" & $cOrig)      ; originator name
        $ord = _ExcelReadCell($rExcel, "P" & $cOrig)                ; originator date
        _ExcelBookClose($rExcel)
        
        $ord = StringLeft(String($ord), 8)
        $ordm = StringRight(StringLeft($ord, 6), 2)
        $ordd = StringRight($ord, 2)
        $ordy = StringLeft($ord, 4)
        $aList[$ia][4] = $ordm & "/" & $ordd & "/" & $ordy
        
        ReDim $aList[UBound($aList) + 1][Ubound($aList, 2)]
        $prog_perc1 += 100 / (Ubound($aFiles) - 3)
        GUICtrlSetData ($prog_bar1, $prog_perc1)
    Next
    
    For $ib = 0 To UBound($aList) - 1
        $cl = 2
        GUICtrlSetData ($prog_label, "Writing..." & @CRLF & $i_path_2)
        Local $oExcel = _ExcelBookOpen($i_path_2, 0)
        
        While _ExcelReadCell($oExcel, "B" & $cl) <> ""
            $cl = $cl+1
        WEnd
        
        _ExcelWriteCell($oExcel, $aList[$ib][0], "B" & $cl)     ; description
        _ExcelWriteCell($oExcel, $aList[$ib][1], "C" & $cl)     ; manufacturer
        _ExcelWriteCell($oExcel, $aList[$ib][2], "D" & $cl)     ; mfg partnumber
        _ExcelWriteCell($oExcel, $aList[$ib][3], "J" & $cl)     ; originator name
        _ExcelWriteCell($oExcel, $aList[$ib][4], "K" & $cl)     ; originator date
        
        _ExcelBookClose($oExcel)
        $prog_perc2 += 100 / Ubound($aList)
        GUICtrlSetData ($prog_bar2, $prog_perc2)
    Next
    
    _MouseTrap()
    
    MsgBox(0, "Done.", "Task is complete.")
    GUISetState (@SW_HIDE, $prog_gui)
EndFunc
Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...