Click here to Skip to main content
15,891,738 members
Articles / Programming Languages / Visual Basic
Article

Animated Progress in Statusbar

Rate me:
Please Sign up or sign in to vote.
3.72/5 (8 votes)
27 Oct 2004 108.3K   551   25   19
Displays an animated progress in windows statusbar, NOT using the progressbar-control!

Image 1

Animation created with Camtasia Studio 2 Evaluation Version

Introduction

This is just a code-snippet with which you can easily display a netscape-like progressbar in your windows-statusbar. It has 2 different modes: (determined by value of the control)
  • -1 = Animated Status, when remaining time is not calculateable
  • 0-100 = Normal Status displaying

How does it work?

It adds its own panel to your statusbar at runtime and handles all drawing in its own class.

The idea is based on Matthew Hazlett Implementation

Using the code

VB.NET
Dim progress1 As ProgressStatus
Private Sub Form1_Load(ByVal sender As System.Object,
  ByVal e As System.EventArgs) Handles MyBase.Load
    progress1 = New ProgressStatus(StatusBar1)
    With progress1
        .Style = StatusBarPanelStyle.OwnerDraw
        .MinWidth = 200
        .BorderStyle = StatusBarPanelBorderStyle.Raised
    End With
    StatusBar1.Panels.Add(progress1)
    Show()
End Sub

You can change the value and the animation speed like following:

VB.NET
progress1.progress = 53  'percent= possible values: 0-100 !
progress1.progress = -1  'animates the bar
progress1.Animspeed= 200 'ms!

Points of Interest

No flickering, because the panel adds its own picturebox and draw then to it!

History

  • 10/28/2004 first release
  • 10/28/2004 (later) 2nd release with own panel-class (no flickering) & cleaner code

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Engineer
Germany Germany
Thomas is interested in technical programming, networking and security technologies.

Currently he's studying at a german university

Comments and Discussions

 
GeneralSample app works great but doesn't when added to another project Pin
AChatelain17-Apr-07 6:43
AChatelain17-Apr-07 6:43 
GeneralRe: Sample app works great but doesn't when added to another project Pin
AChatelain17-Apr-07 6:57
AChatelain17-Apr-07 6:57 
QuestionVB.net Pin
beena shah11-Dec-06 19:33
beena shah11-Dec-06 19:33 
QuestionWorks first time and not again Pin
MMRR2-Aug-06 2:20
MMRR2-Aug-06 2:20 
GeneralAnimated status while loading database query [modified] Pin
abbasy17-Jul-06 0:22
abbasy17-Jul-06 0:22 
QuestionHow to Dispose of this? Pin
moon docker28-Jun-06 8:05
moon docker28-Jun-06 8:05 
QuestionStatus messages? Pin
cknipe30-Nov-05 1:34
cknipe30-Nov-05 1:34 
AnswerRe: Status messages? Pin
cknipe30-Nov-05 2:34
cknipe30-Nov-05 2:34 
GeneralNo refresh when programm has to work hard ... Pin
SMaurer3-Nov-04 23:13
SMaurer3-Nov-04 23:13 
GeneralRe: No refresh when programm has to work hard ... Pin
thomasdev4-Nov-04 2:47
thomasdev4-Nov-04 2:47 
GeneralRe: No refresh when programm has to work hard ... Pin
scott.simmons5-Nov-04 6:48
scott.simmons5-Nov-04 6:48 
GeneralRe: No refresh when programm has to work hard ... Pin
thomasdev6-Nov-04 4:20
thomasdev6-Nov-04 4:20 
GeneralRe: No refresh when programm has to work hard ... Pin
SMaurer6-Nov-04 5:41
SMaurer6-Nov-04 5:41 
GeneralRe: No refresh when programm has to work hard ... Pin
thomasdev6-Nov-04 12:08
thomasdev6-Nov-04 12:08 
GeneralRe: No refresh when programm has to work hard ... Pin
SMaurer6-Nov-04 23:31
SMaurer6-Nov-04 23:31 
GeneralRe: No refresh when programm has to work hard ... Pin
dscemama19-Jan-05 1:46
dscemama19-Jan-05 1:46 
The problem with DoEvent is that it allows the manipulation of the other controls in the form.
I'm developping a form that has several controls to define the search for items, a status bar where I would like to insert your control and a button to launch the search.

Here is an extract of the OnButtonClick function:

       System.Windows.Forms.Cursor.Current = Cursors.WaitCursor<br />
        progress1.progress = -1   ' start your animated control<br />
        fillThread = New Threading.Thread(AddressOf SearchFunction)<br />
        fillThread.Start()<br />
        Do While fillThread.IsAlive<br />
            Application.DoEvents()<br />
            System.Threading.Thread.Sleep(1)<br />
        Loop<br />
        fillThread = Nothing<br />
...<br />
        System.Windows.Forms.Cursor.Current = Cursors.Default<br />


The DoEvent reset the mouse cursor to the default pointer instead of the WaitCursor.
If I add the instruction to change it in the loop, the mouse cursor is ok, but the user has access to all the controls in the form (he can change the values, click again on the search button and even close the form!)

Is there another way to make the control move than DoEvent ?

Thanks
David
GeneralRe: No refresh when programm has to work hard ... Pin
thomasdev20-Jan-05 11:41
thomasdev20-Jan-05 11:41 
GeneralFlickering Pin
Joel Ivory Johnson27-Oct-04 13:19
professionalJoel Ivory Johnson27-Oct-04 13:19 
GeneralRe: Flickering Pin
thomasdev27-Oct-04 22:12
thomasdev27-Oct-04 22:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.