Click here to Skip to main content
Licence 
First Posted 13 Jan 2005
Views 102,214
Bookmarked 87 times

Using Windows Explorer Progress Dialog In Your Application

By | 18 Jan 2005 | Article
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

About the Author

sytelus

Web Developer

United States United States

Member

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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionStrange issue PinmemberT800G12:43 20 Mar '12  
QuestionDelay after calling StartProgressDialog PinmemberKaqkk796:44 20 Mar '12  
AnswerRe: Delay after calling StartProgressDialog PinmemberT800G12:40 20 Mar '12  
GeneralRe: Delay after calling StartProgressDialog PinmemberKaqkk796:02 21 Mar '12  
Generalawesome! Pinmemberjd310685:48 22 May '09  
QuestionGet The Dialog Handle and ... URGENT PLEASE.. Pinmemberamolpbhavsar0:55 25 Nov '08  
QuestionAnother problem, The error occured when .NET Framework 2.0 update the hotfix KB928365 Pinmemberstevenyoung12:16 23 Oct '08  
GeneralLocus lost problem Pinmemberamolpbhavsar2:22 23 Oct '08  
GeneralRe: Locus lost problem Pinmemberapierini22:07 20 Nov '08  
QuestionHow to position the progressDialog in Center of the screen. Pinmemberamolpbhavsar3:35 22 Oct '08  
Is there any method to position the "progressDialog" in the center of the screen. Right now it is coming near the Upper left corner of the form.
 
I am not finding any way to position it in centerscreen
 
Sigh | :sigh:
 
Thanks in advance.....
QuestionHow would I use this to copy a directory with sub-directories PinmemberSreeSatya11:40 1 Aug '06  
QuestionHow can i use this in C# (ASP.Net) ? Pinmembermakadown8:40 3 Oct '05  
AnswerRe: How can i use this in C# (ASP.Net) ? PinmemberScottGBlood0:57 19 May '06  
GeneralMain window will lose focus automatically Pinmemberstevenyoung18:04 18 Feb '05  
GeneralRe: Main window will lose focus automatically Pinmemberamolpbhavsar4:41 23 Oct '08  
GeneralMain window will lose its focus automatically Pinmemberstevenyoung17:01 18 Feb '05  
GeneralThe main window will lose focus when ProgressDialog disposed! Pinmemberstevenyoung16:53 18 Feb '05  
GeneralWithout the interop and slighty faster PinmemberWraith,5:44 20 Jan '05  
GeneralRe: Without the interop and slighty faster PinmemberRussKie12:53 20 Jan '05  
GeneralRe: Without the interop and slighty faster PinmemberWraith,15:16 20 Jan '05  
GeneralRe: Without the interop and slighty faster PinmemberRussKie15:32 20 Jan '05  
GeneralRe: Without the interop and slighty faster PinmemberWraith,16:13 20 Jan '05  
GeneralRe: Without the interop and slighty faster PinmemberRussKie17:49 20 Jan '05  
GeneralRe: Without the interop and slighty faster PinmemberWraith,2:54 22 Jan '05  
GeneralRe: Without the interop and slighty faster PinmemberRussKie22:25 22 Jan '05  

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.

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