PDA

Click to See Complete Forum and Search --> : 3 Better Progress Bars


plenderj
Apr 16th, 2002, 05:39 AM
Here are three progress bars made entirely in code that you can use yourself.
Because they're just made in code with the PictureBox control, there are no extra dependencies.

They also work and look better :)

By plenderj (http://www.vbforums.com/member.php?s=&action=getinfo&userid=14016) : Progress Bar 1 (http://www.vbforums.com/attachment.php?s=&postid=936063)
By RCharlton (http://www.vbforums.com/member.php?s=&action=getinfo&userid=6418) : Progress Bar 2 (http://www.vbforums.com/attachment.php?s=&postid=936069)
By peet (http://www.vbforums.com/member.php?s=&action=getinfo&userid=10426) : Progress Bar 3 (http://www.vbforums.com/attachment.php?s=&postid=936272)

plenderj
Oct 21st, 2004, 09:48 AM
* 21-October-2004 - Moved to CodeBank *

UnKnOwNCoDe
Aug 22nd, 2007, 08:49 AM
Just wanted to add that the last progress bar does not stop at 100%, instead it wraps around and starts over from 0 so it is a continous cycle. To fix this, do the following:

Original Code
Option Explicit

'by peet

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _
ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, _
ByVal ySrc As Long, ByVal dwRop As Long) As Long

Private Const SRCCOPY = &HCC0020

Private Sub GaugeDisplay(dHowMuch As Double)
Dim sPercent As String
Dim iOldScaleMode As Integer
Dim r As Integer
sPercent = Format(dHowMuch, "0%")
Gauge.Cls
InvisGauge.Cls
Gauge.CurrentX = (Gauge.Width - Gauge.TextWidth(sPercent)) / 2
InvisGauge.CurrentX = Gauge.CurrentX
Gauge.CurrentY = (Gauge.Height - Gauge.TextHeight(sPercent)) / 2
InvisGauge.CurrentY = Gauge.CurrentY
Gauge.Print sPercent
InvisGauge.Print sPercent
iOldScaleMode = Gauge.Parent.ScaleMode
Gauge.Parent.ScaleMode = vbPixels
r = BitBlt(Gauge.hDC, 0, 0, InvisGauge.Width * dHowMuch, InvisGauge.Height, InvisGauge.hDC, 0, 0, SRCCOPY)
Gauge.Parent.ScaleMode = iOldScaleMode
End Sub

Private Sub Timer1_Timer()
Static icount As Integer
GaugeDisplay icount / 100
icount = icount + 1
If icount = 101 Then
icount = 0
Label1.Caption = "Download Complete!"
icount = icount
Timer1.Enabled = False

End If
End Sub

Add this right under icount = 0 on Private Sub Timer1_Timer()

Label1.Caption = "Download Complete!"
icount = icount
Timer1.Enabled = False