MFC Common Dialog Box


Home | API | MFC | C++ | C | Previous | Next

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

Display Code Download Code


Home | API | MFC | C++ | C | Previous | Next

Creating a Simple Window | Processing Messages | Device Context | Working with Graphics | Mapping Modes | Text Output | Working with the Mouse | Dealing with Keyboard Input | Drawing Lines and Shapes | Adding Menus | Child Windows | Dialog Windows | Common Dialog Box | Working with Bitmaps | Common Controls | Toolbars | Document View Architecture | Multi Document Interface | Timers | MFC Collections Classes

Last Updated: 15 September 2022