SUMMARY
The Microsoft Foundation Classes (MFC) Standard Dialog
Classes provide convenient C++ wrappers for the Microsoft Windows Common Dialog
Boxes dynamic-link library (DLL), COMMDLG.DLL. To customize one of these
classes, you may need to modify some of the default parameter block members.
The wrapper functions use the same parameter blocks as the corresponding common
dialog functions because, ultimately, the code calls the Windows functions.
Microsoft
Foundation Classes Windows Common Dialog Parameter Block
-------------------------------------------------------------------
CFileDialog GetOpenFileName and OPENFILENAME
GetSaveFileName
CFontDialog ChooseFont CHOOSEFONT
CColorDialog ChooseColor CHOOSECOLOR
CPrintDialog PrintDlg PRINTDLG
CFindReplaceDialog FindText and FINDREPLACE
ReplaceText
For Microsoft Foundation Classes version 1.0, distributed with
Microsoft C/C++ version 7.0, Technical Note #13 provides additional information
about these classes and how to use them. Technical Note #13 is in the TN013.TXT
file in the MFC\DOC directory (by default, C:\C700\MFC\DOC). For Microsoft
Foundation Classes library versions 2.x, 3.x, and 4.x, each of these functions
is listed in the online documentation and in the "Class Library Reference"
manual by its class name.
Even though the parameter block defaults
that the Microsoft Foundation Classes library provides are generally adequate,
there are times it may be necessary to customize a dialog box. For example, it
may be helpful to specify the OFN_ALLOWMULTISELECT flag with the CFileDialog to
allow the user to select more than one file in the GetOpenFileName dialog box.
If you add a flag, however, you must be careful to provide any
additional information as appropriate. For example, CFileDialog provides a
default buffer m_szFileName that is _MAX_PATH characters in length. If you
allow the user to select more than one file, this buffer capacity can be
exhausted quickly.
Even though the CFileDialog class was designed
with a buffer to support only one file, it is an easy matter to provide your
own buffer by setting the m_ofn.lpstrFile and m_ofn.nMax members of the
OPENFILENAME parameter block yourself after constructing your CFileDialog, but
before calling DoModal().
The text below demonstrates this method of
replacing the default CFileDialog buffer. However, similar techniques apply to
any of the standard dialog box classes. In general, when you change any of the
default flags, you should examine the Microsoft Foundation Classes library
source code to determine the effects of the change, if any, and to take
appropriate action.