Re: 3 Better Progress Bars
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
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()
Code:
Label1.Caption = "Download Complete!"
icount = icount
Timer1.Enabled = False