Working with the CommonDialog Control

The CommonDialog control is an ActiveX control that provides access to the Windows CE common dialog boxes. A common dialog box is a system-defined dialog box that standardizes how users perform complex operations common to most applications, such as opening and closing files. The control supports the Color, Open, Save As, and Font common dialog boxes. In addition, you can use the control to display a Windows CE Help file.

For each type of common dialog box, the CommonDialog control has an associated method used to open each dialog box. The control also has properties that define the appearance of the dialog boxes. For example, the ShowColor method opens a Color dialog box, and the Flags property enables or disables user choices that affect appearance, such as adding custom colors.

While a dialog box is open, a user can make a selection, such as choosing a font, color, or file name. When the user accepts the selections, the properties of the control change to reflect the user’s choices. However, when the user cancels a dialog box without choosing a font, color, or file name, you may want your application to respond to the event. You can set the CancelError property to True to cause the control to generate an error if a user chooses a cancel button while a dialog box is open.

Because the properties of the CommonDialog control change in response to user input, you should verify that the properties of the control are set correctly each time the common dialog box is displayed.