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 color selection. All the common dialog classes are derived from a common base class, CCommonDialog.

The behavior and appearance of a common dialogue by set or altered 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.

Edit
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 details reading
https://docs.microsoft.com/en-us/cpp/mfc/reference/ccommondialog-class?view=vs-2019


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 boxmfc-common-dialog-image.

#include <afxwin.h>
#include <afxdlgs.h>
#define BUTTON 1000
 
class CSimpleApp : public CWinApp
{
public:
BOOL InitInstance();
};
 
class CMainFrame : public CFrameWnd
{
public:
void refreshwindows(WPARAM, LPARAM );
CMainFrame();
afx_msg void modelessButtonClick();
afx_msg void modalButtonClick();
DECLARE_MESSAGE_MAP()
CButton Button;
afx_msg void OnPaint();
COLORREF wcolor;
}; 
 
BOOL CSimpleApp::InitInstance(){
m_pMainWnd = new CMainFrame();
m_pMainWnd->ShowWindow(m_nCmdShow);
return true;
} 
 
CMainFrame::CMainFrame()
{
Create(NULL, "MFC Colour dialog",WS_OVERLAPPEDWINDOW ,CRect(25,25,410,200));
Button.Create ("Colour dialog",BS_DEFPUSHBUTTON| WS_CHILD | WS_VISIBLE , CRect(12,12,150,62), this,BUTTON);
wcolor=RGB(255,255,255);
}
 
BEGIN_MESSAGE_MAP(CMainFrame,CFrameWnd)
ON_BN_CLICKED(BUTTON,modelessButtonClick)
ON_WM_PAINT()
END_MESSAGE_MAP()
 
CSimpleApp MFCApp1;
 
//selects modeless dialog when button clicked
afx_msg void CMainFrame::modelessButtonClick()
{
CColorDialog Tmp( 0, CC_ANYCOLOR | CC_RGBINIT, this );
if( Tmp.DoModal() == IDOK )
{
CString Msg;
Msg.Format( "You selected color %d", Tmp.GetColor() );
wcolor = Tmp.GetColor();
Invalidate();
}
}
 
afx_msg void CMainFrame::OnPaint()
{
CPaintDC paintDC(this);
CRect rect;
GetClientRect(&rect);
paintDC.FillSolidRect(&rect,wcolor);
}


Download