There are several types of common dialog available in windows operating system. Common dialogs are popup dialog windows available as components to take verious input parameters from users.
These are some functionalities common dialogs provide to users-
- Selecting a file name with path in graphical environment for opening or saving a file.
- Selecting a system font and size and other attributes with preview.
- Selecting a color value for graphical or multimedia application
- Printer selection for prining text or graphical output of the program
- Pagesetup of the program output.
- Find and or replace string and parameter input from user
These are built in dialog resources with their additional functionalities. Programmers need not to implement these from scratch but still can reuse these and extend the functionality in their application. These dialogs can be invoked via Win32 API calls directly. However MFC wraps these inside meaningful classes to maintain object oriented approach.
Common dialog pictures
Common dialog Win32 APIs
Programmers need to include comdlg.h file in their C/C++ files and comdlg32.lib is the import library to include during link time.
- GetOpenFileName: File Open dialog
- GetSaveFileName: File Save dialog
- ChooseFont: Font choose dialog
- ChooseColor: Color picker dialog
- PageSetupDlg: Printer page setup dialog
- PrintDlg: Print dialog
- FindText: File text find dialog
- ReplaceText: File text replace dialog
Common dialog MFC classess
CCommonDialog is the base class for classes that encapsulate functionality of the Windows common dialogs. afxdlgs.h is the header file to include in MFC application. Following are the class name of the dialog:
- CFileDialog: File Open/Save dialog
- CFontDialog: Font choose dialog
- CColorDialog: Color picker dialog
- CPageSetupDialog: Printer page setup dialog
- CPrintDialog: Print dialog
- CFindReplaceDialog: File find/replace dialog
About our authors: Team EQA
MFC hides WinMain in its framework and includes source file on WinMain(). This explains how framework calls global CWinApp::Initinstance() from entry WinMain.
This is constructed during global C++ objects are constructed and is already available when Windows calls the WinMain function, which is supplied by the ...
Define a custom Window class structure, Register the class name, CreateWindow, Show windows and write message get and dispatch loop statements. Define the Window CallBack procedure and write the handlers.
DispatchMessage() is a API which indirectly triggers the Window CallBack procedure. Message structure members from this function are passed to the CallBack procedure. CallBack procedure should implement event handlers depending on the need of the application.
LPARAM and WPARAM are the two parameters in Window CallBack procedure. They signifies parameters of various events. They are used in handing individual events.
We need to write WinMain and need to follow all these in a Win32 application. However we need not to write much if we are writing an application with MFC ...
Learn on Youtube