This source code is for Visual Basic 5 or 6, it should load and compile cleanly in either one. It was written using the MS Visual Studio IDE, and tested numerous times in production programs of both my own and others. If you use any of this and find a bug, or just want to tell me it was useful, please contact me to tell me about it.
Visual Basic
A small class to replace the common dialog OCX for Visual Basic 5 or 6, by using the Windows API instead of the ActiveX control or DLLs. No more version conflicts. No DLL Hell. No bulk added to your install or application. Just clean, easy to use code wrapped in a class with an example program. If you're looking for a VB.NET version of this, here it is.Updated: 12/05/05 Mike at Vellosoft found a bug that affects font selection in WindowsME and emailed me the fix, which is incorporated in the current download. Mike has found and fixed other things in this class over the years, he's at least as responsible as I am for the current stability of this class. Check out his software, he has some pretty nifty applications.
Common Dialogs Class
The source code for the common dialogs class is a class that enables you to use the file open, save, print, and other dialogs from within your application without having to put the control on your forms. So how is this a benefit? Because all the properties are set by default, so you don't have to waste time setting them. Better control over the dialogs is provided through exposing more properties. The Browse for Folder dialog is provided. A history of the files and folders is kept. In every way this class is better than the default MS common dialog control. The code is clean and well documented, with an example program provided.
How do you use it?
Just dim an object somewhere in your application where it will have scope through the whole program. Then call a method (function) each time you need a common dialog. The dialog will fire and the function method will return the result, whether it's a file name or a color. Simple, easy, lightweight. It's been tested repeatedly in production, including Visual Basic and Access applications. Check out the example program included with the code; it shows all the functionality, and more, of the standard common dialog control.
Advantages
- You don't have to use or include any ActiveX (OCX) or DLL files
- It's fast: pure Win32 API code
- It's portable: no DLL Hell. No version conflicts. It just works
- More dialogs than are included in the MS common dialogs control
- More control: it keeps a history of files and folders, which you can use in your program
- More properties, more methods than the default common dialogs control
- Lightweight: doesn't use as much memory or disk space as the common dialog control
