Common dialogs are a set of predefined, standard dialogs that can be used in an application to carry out common tasks such as file selection, font selection, or colour selection. All the common dialog classes are derived from a common base class, CCommonDialog.
The behaviour and appearance of a common dialogue by set or altered by changing the parameters supplied to the dialog’s constructor or by setting various flags. All the common dialogs require the inclusion of the commdlg.h header file.
MFC CCommonDialog Classes are shown in the following table.
Class | Purpose |
---|---|
CColorDialog | Allows the user to select or create a color |
CFileDialog | Allows the user to open or save a file |
CFindReplaceDialog | Allows the user to substitute one string for another |
CFontDialog | Allows the user to select a font from a list of available fonts |
COleDialog | Useful for inserting OLE objects |
CPageSetupDialog | Allows the user to set page measurement parameters |
CPrintDialog | Allows the user to set up the printer and print a document |
CPrintDialogEx | Printing and Print Preview for Windows 2000 |
For further detailed reading
https://docs.microsoft.com/en-us/cpp/mfc/reference/ccommondialog-class?view=vs-2019
Example
The following short program illustrates the use of the CColourDialog by changing the background colour of the windows to match that selected from the colour dialog box
Download Code