Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitlePlace progress indicators above a StatusBar control
DescriptionThis example shows how to place progress indicators above a StatusBar control in Visual Basic 6. The program positions a ProgressBar and button over panels in the StatusBar whenever the form is resized.
KeywordsStatusBar, ProgressBar, animation, progress indicator, working
CategoriesControls, Graphics, Multimedia
 
Thanks to Dipak Auddy.

Whenever the form resizes, the program moves its ProgressBar and button control over their panels in the StatusBar.

 
Private Sub Form_Resize()
    'unset the alignment of statusbar
    'this is necs. for calculating the current positons
    'of statusbar.
    StatusBar1.Align = 0
    MoveControls
End Sub

'move progressbar and button into the statusbar
Private Sub MoveControls()
    Dim X As Single
    'Around 2 pixels for boderning
    X = ScaleY(2, vbPixels, vbTwips)
    'reset the statusbar to bottom of the form.
    'so now we have current positions of it...
    StatusBar1.Align = 2

    ProgressBar1.Move _
        StatusBar1.Panels(1).Left, _
        StatusBar1.Top + X, _
        StatusBar1.Panels(1).Width, _
        StatusBar1.Height - X
    ProgressBar1.ZOrder

    cmdGo.Move _
        StatusBar1.Panels(2).Left, _
        StatusBar1.Top + X, _
        StatusBar1.Panels(2).Width - X, _
        StatusBar1.Height - X
    cmdGo.ZOrder
End Sub
 
When the user presses the Go button, the program resets its values and enables a timer. When the timer fires, its event handler updates the ProgressBar and the Working... message.
 
'reset all values...
Private Sub cmdGo_Click()
    Label1.Caption = "A Demo by Dipak Auddy"
    ProgressBar1.Value = ProgressBar1.Min
    ProgressBar1.Visible = True
    cmdGo.Visible = False
    StatusBar1.Panels(2).Text = "Working..."
    Me.MousePointer = vbHourglass
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    If ProgressBar1.Value + 5 > ProgressBar1.Max Then
        ' Stop.
        Timer1.Enabled = False
        ProgressBar1.Visible = False
        cmdGo.Visible = True
        Label1.Caption = "Click 'Go' to continue"
        cmdGo.SetFocus
        Me.MousePointer = vbNormal
    Else
        ' Keep going.
        ProgressBar1.Value = ProgressBar1.Value + 5
        If StatusBar1.Panels(2).Text = "Working..." Then
            StatusBar1.Panels(2).Text = ""
        Else
            StatusBar1.Panels(2).Text = "Working..."
        End If
    End If
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated