The Common Dialog Box Library provides a collection of predefined Windows dialog boxes for performing frequently used tasks. These standard dialogs provide a consistent user interface across Windows applications, allowing users to interact with familiar controls and workflows.
The library includes dialog boxes for:
- Opening files
- Saving files
- Choosing a printer
- Finding and replacing text
- Selecting fonts
- Choosing colours
- Displaying help information (legacy)
Using common dialog boxes helps ensure that an application follows the standard Windows look and feel. It also improves usability and reduces the amount of code that developers need to write and maintain.
The functions and data structures used by the Common Dialog Box Library are declared in the COMMDLG.H header file. To use a common dialog, an application typically performs the following steps:
- Declare and initialise the appropriate dialog box structure, such as
OPENFILENAME,CHOOSECOLOR, orCHOOSEFONT. - Set the required fields of the structure, such as the owner window, file filters, initial directory, or default values.
- Pass a pointer to the structure to the appropriate common dialog function.
- When the user closes the dialog box, the function returns control to the application. If the user confirms the operation, the structure contains the information selected or entered by the user.
Each common dialog function returns a value indicating whether the user completed the operation successfully or cancelled the dialog, allowing the application to respond accordingly.
For further reading https://docs.microsoft.com/en-us/windows/win32/dlgbox/dialog-box-types
The examples below demonstrate several common dialog boxes, including text find and replace, file open and save, colour selection, font selection, and printer selection.
Select Colour Common Dialog Box
The Select Colour Dialog Box displays a basic set of available colours and also allows the user to create custom colours by specifying RGB values.

File Open/Save Common Dialog Box
The Common File Open/Save dialog provides a consistent interface for file management operations using the standard Windows dialog interface.
The Open dialog box allows the user to specify the drive, directory, and name of a file or set of files to open.
The Save As dialog box allows the user to specify the drive, directory, and name of a file to save.

Find and Replace Common Dialog Box
The Find and Replace Common Dialog Box displays a modeless dialog box that allows the user to specify a string to search for within a text document, together with additional options for finding and replacing text.

Font Common Dialog Box
The Font Common Dialog Box allows the user to select a font, style, size, and optional text effects using the standard Windows Font dialog.
Choose Printer Common Dialog Box
The Printer Common Dialog Box displays the standard Windows Print dialog, allowing the user to select a printer, choose the number of copies, and specify available print options before printing.