.netPlus / Samples / VB



VBBubble screenshot


Filename: progdlg.zip
Last update: 01/11/01
Size: 15 kb


Ever since Windows 95, you've seen a progress dialog when you copy or move files 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.

This sample demonstrates how to use this progress dialog object from VB, using a type library included in the ZIP file. It also demonstrates how to use the CopyFileEx and MoveFileWithProgress API functions to copy or move a file and recieve progress notifications to a callback routine.

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.


In the original release of Windows 2000, and with Service Pack 1, there were (at least) two bugs in the implementation of the progress dialog object that you should be aware of. Both of them have been fixed in Service Pack 2.

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.

You can work around both these bugs, if your code must run in Windows 2000 pre-SP2. 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. To solve the second one, you can use the PathSetDlgItemPath API to set the text of the controls in the dialog instead of calling the SetLine method.



2000-2014, .netPlus