4. More Exploration of the Visual Basic Toolbox
Common Dialog Boxes
- The primary use for the drive, directory, and file name list boxes
is to develop custom file access routines. Two common file access routines
in Windows-based applications are the Open File and Save File
operations. Fortunately, you don�t have to build these routines.
- To give the user a standard interface for common operations in
Windows-based applications, Visual Basic provides a set of
common dialog boxes, two of which are the Open and
Save As dialog boxes. Such boxes are familiar to any Windows
user and give your application a professional look. And, with Windows 95,
some context-sensitive help is available while the box is displayed.
Appendix II lists many symbolic constants used with common dialog boxes.
- The Common Dialog control is a �custom control� which means
we have to make sure some other files are present to use it. In normal
setup configurations, Visual Basic does this automatically. If the common
dialog box does not appear in the Visual Basic toolbox, you need to add
it. This is done by selecting Components under the Project menu.
When the selection box appears, click on Microsoft Common Dialog
Control, then click OK.
- The common dialog tool, although it appears on your form, is
invisible at run-time. You cannot control where the common dialog
box appears on your screen. The tool is invoked at run-time using
one of five �Show� methods. These methods are:
| Method |
Common Dialog Box |
| ShowOpen |
Open dialog box |
| ShowSave |
Save As dialog box |
| ShowColor |
Color dialog box |
| ShowFont |
Font dialog box |
| ShowPrinter |
Printer dialog box |
- The format for establishing a common dialog box named cdlExample
so that an Open box appears is:
Control to the program returns to the line immediately following this
line, once the dialog box is closed in some manner. Common dialog boxes
are system modal.
- Learning proper use of all the common dialog boxes would require an
extensive amount of time. In this class, we�ll limit ourselves to
learning the basics of getting file names from the Open and
Save As boxes in their default form.
Counter Hit
This Homepage is special brought to you by CK Tan