Click here to Skip to main content
11,645,087 members (65,279 online)
Click here to Skip to main content

Using Windows Explorer Progress Dialog In Your Application

, 18 Jan 2005 120.6K 2K 88
Rate this:
Please Sign up or sign in to vote.
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.

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

Share

About the Author

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

You may also be interested in...

Comments and Discussions

 
QuestionStrange issue Pin
T800G20-Mar-12 12:43
memberT800G20-Mar-12 12:43 
QuestionDelay after calling StartProgressDialog Pin
Kaqkk7920-Mar-12 6:44
memberKaqkk7920-Mar-12 6:44 
AnswerRe: Delay after calling StartProgressDialog Pin
T800G20-Mar-12 12:40
memberT800G20-Mar-12 12:40 
GeneralRe: Delay after calling StartProgressDialog Pin
Kaqkk7921-Mar-12 6:02
memberKaqkk7921-Mar-12 6:02 
Generalawesome! Pin
jd3106822-May-09 5:48
memberjd3106822-May-09 5:48 
QuestionGet The Dialog Handle and ... URGENT PLEASE.. Pin
amolpbhavsar25-Nov-08 0:55
memberamolpbhavsar25-Nov-08 0:55 
QuestionAnother problem, The error occured when .NET Framework 2.0 update the hotfix KB928365 Pin
stevenyoung23-Oct-08 12:16
memberstevenyoung23-Oct-08 12:16 
After the hotfix KB928365 downloaded and installed by Automatically update, the error will occur. It will work well if you uninstall the hotfix or reinstall .NET Framework 2.0, could you please test it and solve this problem? thank you.
GeneralLocus lost problem Pin
amolpbhavsar23-Oct-08 2:22
memberamolpbhavsar23-Oct-08 2:22 
GeneralRe: Locus lost problem Pin
apierini20-Nov-08 22:07
memberapierini20-Nov-08 22:07 
QuestionHow to position the progressDialog in Center of the screen. Pin
amolpbhavsar22-Oct-08 3:35
memberamolpbhavsar22-Oct-08 3:35 
QuestionHow would I use this to copy a directory with sub-directories Pin
SreeSatya1-Aug-06 11:40
memberSreeSatya1-Aug-06 11:40 
QuestionHow can i use this in C# (ASP.Net) ? Pin
makadown3-Oct-05 8:40
membermakadown3-Oct-05 8:40 
AnswerRe: How can i use this in C# (ASP.Net) ? Pin
ScottGBlood19-May-06 0:57
memberScottGBlood19-May-06 0:57 
GeneralMain window will lose focus automatically Pin
stevenyoung18-Feb-05 18:04
memberstevenyoung18-Feb-05 18:04 
GeneralRe: Main window will lose focus automatically Pin
amolpbhavsar23-Oct-08 4:41
memberamolpbhavsar23-Oct-08 4:41 
GeneralMain window will lose its focus automatically Pin
stevenyoung18-Feb-05 17:01
memberstevenyoung18-Feb-05 17:01 
GeneralThe main window will lose focus when ProgressDialog disposed! Pin
stevenyoung18-Feb-05 16:53
memberstevenyoung18-Feb-05 16:53 
GeneralWithout the interop and slighty faster Pin
Wraith,20-Jan-05 5:44
memberWraith,20-Jan-05 5:44 
GeneralRe: Without the interop and slighty faster Pin
RussKie20-Jan-05 12:53
memberRussKie20-Jan-05 12:53 
GeneralRe: Without the interop and slighty faster Pin
Wraith,20-Jan-05 15:16
memberWraith,20-Jan-05 15:16 
GeneralRe: Without the interop and slighty faster Pin
RussKie20-Jan-05 15:32
memberRussKie20-Jan-05 15:32 
GeneralRe: Without the interop and slighty faster Pin
Wraith,20-Jan-05 16:13
memberWraith,20-Jan-05 16:13 
GeneralRe: Without the interop and slighty faster Pin
RussKie20-Jan-05 17:49
memberRussKie20-Jan-05 17:49 
GeneralRe: Without the interop and slighty faster Pin
Wraith,22-Jan-05 2:54
memberWraith,22-Jan-05 2:54 
GeneralRe: Without the interop and slighty faster Pin
RussKie22-Jan-05 22:25
memberRussKie22-Jan-05 22:25 
GeneralRe: Without the interop and slighty faster Pin
Wraith,23-Jan-05 0:54
memberWraith,23-Jan-05 0:54 
GeneralRe: Without the interop and slighty faster Pin
RussKie23-Jan-05 10:45
memberRussKie23-Jan-05 10:45 
GeneralRe: Without the interop and slighty faster Pin
Wraith,23-Jan-05 10:48
memberWraith,23-Jan-05 10:48 
GeneralRe: Without the interop and slighty faster Pin
RussKie24-Jan-05 0:10
memberRussKie24-Jan-05 0:10 
GeneralMissing bits Pin
Joe Fuentes19-Jan-05 3:43
memberJoe Fuentes19-Jan-05 3:43 
GeneralRe: Missing bits Pin
sytelus19-Jan-05 6:28
membersytelus19-Jan-05 6:28 
GeneralSlow and irresponsive... Pin
RussKie16-Jan-05 19:48
memberRussKie16-Jan-05 19:48 
GeneralRe: Slow and irresponsive... Pin
sytelus18-Jan-05 10:56
membersytelus18-Jan-05 10:56 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150731.1 | Last Updated 18 Jan 2005
Article Copyright 2005 by sytelus
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid