The CommonDialog control provides a standard set of dialog boxes for operations such as opening and saving files, and selecting colors and fonts. The control also has the ability to display help by running the Windows Help engine.
CommonDialog
CEComDlg
MSCEComDlg.dll
The CommonDialog properties, methods, and events listed in the following table are supported:
You use the CommonDialog control in your application by adding it to a form and setting its properties. The dialog displayed by the control is determined by the methods of the control. At run time, a dialog box is displayed or the help engine is executed, when the appropriate method is invoked; at design time, the CommonDialog control is displayed as an icon on a form. This icon cannot be sized.
The CommonDialog control can display the following commonly used dialog boxes:
When you draw a CommonDialog control on a form, it automatically resizes itself. The CommonDialog control is invisible at run time
Method | Dialog Box Displayed |
---|---|
ShowOpen | Open |
ShowSave | SaveAs |
ShowColor | Color |
ShowFont | Font |
ShowHelp | Invokes the Windows Help Engine |
Note In Windows CE, common dialog boxes are not movable; they are always centered vertically and horizontally on the screen. Common dialog boxes in Windows CE always have the Help button displayed.
The Color Dialog Box
The Color common dialog box enables the user to select a color from a palette or to create and select a custom color. At run time, when the user chooses a color and closes the dialog box, you use the Color property to get the selected color.
Use the Color property to get the RGB value of the color the user selects.
The Open and Save As Dialog Boxes
The Open common dialog box provides users with a way to select a file to open.
The Save As common dialog box is identical to the Open dialog box in appearance, except for the dialog's caption, and file names appearing dimmed out. At run time, when the user chooses a file and closes the dialog box, the FileName property is used to get the selected file name.
After the user chooses a file, use the FileName property to get the name of the selected file.
With all the common dialog boxes, when the CancelError property is True, an error is generated when the user clicks the dialog box's Cancel button. You detect that the Cancel button was pressed by trapping the error when the dialog box is displayed.
The Font Dialog Box
The Font dialog box enables the user to select a font by its size, color, and style.
Note You must set the Flags property to one of these values before displaying the Font dialog box. Otherwise, the following error occurs:
No Font Exists
Displaying a Help File
The ShowHelp method of the common dialog control allows you to display a Help file.