VB+ IProgressDialog sample - 4/18/00
====================================
Copyright 2000, Mattias Sjgren
Homepage: http://hem.spray.se/mattias.sjogren/
E-mail: mattiass@hem.passagen.se


Overview
--------

The sample code in this ZIP file demonstrates how to use the system progress dialog COM object through the IProgressDialog interface, and how to use the CopyFileEx and MoveFileWithProgress API functions to get progress information for file operations.

If you want to do these things together in a real application, you should of course use the SHFileOperation API instead, since it's easier and more powerful. But progress dialogs are useful for many other things, and so are file operation progress notifications. 

The sample was developed in VB6, but should hopefully work well with VB5 too (if it doesn't, please let me know). You need Windows 2000 to try it.

Read more about progress dialogs at

http://msdn.microsoft.com/library/psdk/shellcc/shell/IFaces/IProgressDialog/IProgressDialog.htm



Details
-------

Ever since Windows 95, you've seen a progress dialog when you copy or move in Explorer. The dialog displays an AVI animation, a few lines of text, a progress bar and a Cancel button.

In Windows 2000, this dialog has been wrapped in a reusable COM class implemented by the shell. The COM object is accessed through the IProgressDialog interface. You can customize the dialog title, AVI animation, text lines and a few other things. The system can also
calculate the remaining time of the operation and display it on one of the lines if you wish.


The CopyFileEx API was available already in Windows NT 4. It can give you progress information to a callback procedure while copying a file, and you have the ability to cancel the operation if you need. In Windows 2000, a new function called MoveFileWithProgress gives you the same information when moving a file.



Bugs
----

There are (at least) two bugs in the implementation of the progress dialog object that you should be aware of. They exist in the release version of Windows 2000, but since they both have been reported to Microsoft, they should hopefully be fixed in future service packs.

The first one is that the PROGDLG_NOMINIMIZE flag (StartProgressDialog method) doesn't have any effect. The dialog will have a minimize button whether you set it or not. The second bug is that the fCompactPath parameter of the SetLine method doesn't have any effect either. Paths that are wider than the dialog width will be clipped at the end, not compacted using PathCompactPath as the documentation claims.

Fortunately, you can work around both these bugs. The progress dialog object implements the IOleWindow interface in addition to IProgressDialog. Using the GetWindow method of IOleWIndow, you can obtain the window handle of the dialog box. Having that, you have full control over its appearance.

The sample code demonstrates how to work around the PROGDLG_NOMINIMIZE bug. With a little more work (calling PathCompactPath yourself etc.) you can work around the other bug too.



History
-------

4/18/00 - The type library not contains IOleWindow as well, and the sample code includes a workaround for PROGDLG_NOMINIMIZE bug.
          Unicode API support removed.

4/1/00  - Initial release.



Distribution
------------

You are allowed to use the included code and type library within your own software, both for private and public use. You are not required to credit the author in any way, although it's always appreciated.

However, you are not allowed to redistribute this sample as source code by any means, without the authors permission. Instead, please refer to the webpage found at the top of this document.


Feedback
--------

Please send comments or questions to mattiass@hem.passagen.se

Visit http://hem.spray.se/mattias.sjogren/ for updates.
