5,691,626 members and growing! (13,195 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » .NET Framework » How To     Intermediate

Using Windows Explorer Progress Dialog In Your Application

By sytelus

A simple .NET wrapper that lets you use IProgressDialog interface to show standard Windows progress dialog with AVI animation and built-in time remaining calculation.
VB, HTML, Windows, .NET, .NET 1.0, .NET 1.1, .NET 2.0, WinForms, VS.NET2002, VS.NET2003, VS2005, Visual Studio, Dev

Posted: 13 Jan 2005
Updated: 18 Jan 2005
Views: 62,845
Bookmarked: 71 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
13 votes for this Article.
Popularity: 4.67 Rating: 4.19 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
1 vote, 7.7%
3
5 votes, 38.5%
4
7 votes, 53.8%
5

Sample Image - ProgressDialogDemo.jpg

Introduction

When you copy a large file in Explorer, you see the standard Windows progress dialog coming up with "flying papers" animation with the calculation of estimated time remaining. This dialog is accessible to any Windows application through IProgressDialog interface. While this interface is pretty simple and intuitive to use, more often than not, many developers are unaware of its existence spending lot of time in replicating exactly the same functionality. The goal of this article is to create awareness about this interface and to provide an even simpler managed .NET wrapper to use this functionality.

Background

The current article is based on another article on using IProgressDialog in VB6 at msjogren.com. The current article uses the same .TLB file as in that article to create the managed .NET wrapper and adds-on few little extras such as additional animation styles.

Using the code

Warning: There is a default two second delay before the dialog appears. This seems to be default behavior.

Using the code is pretty easy as can be seen in the following snippet:

        Dim progressDialog As New WinProgressDialog.ProgressDialog
        Try
            progressDialog.Show(Me.Handle.ToInt32, "descr1", "Descr2", MaxValue)
            progressDialog.UpdateProgress(progress, detail)
        Finally
            progressDialog.Dispose()
        End Try

You might want to check the return value to see if the user has pressed the Cancel button. This you can also check by calling HasUserCancelled.

Many times, you just want to show an animation without progress dialog (like showing flashlight when performing search). You can do this by setting ProgressBarVisible to False.

Points Of Interests

Notice the use of LoadLibrary and FreeLibrary to get the handle of standard animations from shell32.dll. It's possible to use your own custom animation instead of standard ones available through StandardProgressAnimations Enum.

A Dispose is required to make sure a call to FreeLibrary was made and also to Marshal.ReleaseComObject on main dialog.

The Interop.VBProgressDialog.dll which is referenced by the project is automatically generated by VS.NET when progdlg.tlb is referenced. If you need to sign the DLL, then you will need to manually generate a signed version of interop using tlbimp.

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

About the Author

sytelus


Shital Shah is a Software Engineer and is passionate about physics, mathematics and learning algorithms. You can reach him through his website and blog.
Occupation: Web Developer
Location: United States United States

Other popular .NET Framework articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 28 (Total in Forum: 28) (Refresh)FirstPrevNext
QuestionGet The Dialog Handle and ... URGENT PLEASE..memberamolpbhavsar1:55 25 Nov '08  
QuestionAnother problem, The error occured when .NET Framework 2.0 update the hotfix KB928365memberstevenyoung13:16 23 Oct '08  
GeneralLocus lost problemmemberamolpbhavsar3:22 23 Oct '08  
GeneralRe: Locus lost problemmemberapierini23:07 20 Nov '08  
QuestionHow to position the progressDialog in Center of the screen.memberamolpbhavsar4:35 22 Oct '08  
GeneralHow would I use this to copy a directory with sub-directoriesmemberSreeSatya12:40 1 Aug '06  
GeneralHow can i use this in C# (ASP.Net) ?membermakadown9:40 3 Oct '05  
GeneralRe: How can i use this in C# (ASP.Net) ?memberScottGBlood1:57 19 May '06  
GeneralMain window will lose focus automaticallymemberstevenyoung19:04 18 Feb '05  
GeneralRe: Main window will lose focus automaticallymemberamolpbhavsar5:41 23 Oct '08  
GeneralMain window will lose its focus automaticallymemberstevenyoung18:01 18 Feb '05  
GeneralThe main window will lose focus when ProgressDialog disposed!memberstevenyoung17:53 18 Feb '05  
GeneralWithout the interop and slighty fastermemberWraith,6:44 20 Jan '05  
GeneralRe: Without the interop and slighty fastermemberRussKie13:53 20 Jan '05  
GeneralRe: Without the interop and slighty fastermemberWraith,16:16 20 Jan '05  
GeneralRe: Without the interop and slighty fastermemberRussKie16:32 20 Jan '05  
GeneralRe: Without the interop and slighty fastermemberWraith,17:13 20 Jan '05  
GeneralRe: Without the interop and slighty fastermemberRussKie18:49 20 Jan '05  
GeneralRe: Without the interop and slighty fastermemberWraith,3:54 22 Jan '05  
GeneralRe: Without the interop and slighty fastermemberRussKie23:25 22 Jan '05  
GeneralRe: Without the interop and slighty fastermemberWraith,1:54 23 Jan '05  
GeneralRe: Without the interop and slighty fastermemberRussKie11:45 23 Jan '05  
GeneralRe: Without the interop and slighty fastermemberWraith,11:48 23 Jan '05  
GeneralRe: Without the interop and slighty fastermemberRussKie1:10 24 Jan '05  
GeneralMissing bitsmemberJoe Fuentes4:43 19 Jan '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 18 Jan 2005
Editor: Smitha Vijayan
Copyright 2005 by sytelus
Everything else Copyright © CodeProject, 1999-2008
Web08 | Advertise on the Code Project