Results 1 to 3 of 3

Thread: 3 Better Progress Bars

  1. #1

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    3 Better Progress Bars

    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 : Progress Bar 1
    By RCharlton : Progress Bar 2
    By peet : Progress Bar 3
    Last edited by plenderj; May 23rd, 2002 at 03:38 AM.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  2. #2

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    * 21-October-2004 - Moved to CodeBank *
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Lively Member
    Join Date
    Aug 2007
    Posts
    123

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width