A SERVICE OF

logo

FontData.SizeMin = 0;
FontData.SizeMax = 0;
if (TChooseFontDialog(this, FontData).Execute() == IDOK) {
delete Font;
Color = FontData.Color;
Font = new TFont(&FontData.LogFont);
}
Invalidate();
}
The file-open common dialog box serves as a consistent replacement for the
Using file open
many different types of dialog boxes applications have used to open files.
common dialog
TOpenSaveDialog::TData has several members you must initialize before
boxes
constructing the dialog box object. Y u can either initialize them byo
assigning values, or you can use TOpenSaveDialog::TData’ constructors ,
which takes Flags, Filter, CustomFilter, InitialDir, and DefExt (the most
common) as parameters with default arguments of zero.
__________________________________________________________________________
Table 8.5
TData
member T pe Descriptiony
File open and save
____________________________________________________________________
common dialog box
FileName
char* The selected file name. On input, it specifies the default file
TData data members
name. On output, it contains the selected file name.
Filter
char* The file name filters and filter patterns. Each filter and filter
pattern is in the form:
filter|filter pattern
|...
where
filter
is a text string that describes the filter and
filter
pattern
is a DOS wildcard file name. Y u can repeat
filter
ando
filter pattern
for as many filters as you need. Y u musto
separate them with
|
characters.
CustomFilter
char* Lets you specify custom filters.
FilterIndex
int Specifies which of the filters specified in
Filter
should be
displayed by default.
InitialDir
char* The directory to be displayed on opening the file dialog box.
Use zero for the current directory.
DefExt
char* Default extension appended to
FileName
if the user doesn’t
type an extension. If
DefExt
is zero, no extension is
appended.
____________________________________________________________________
In this example, a file-open common dialog box prompts the user for a file
name. If an error occurred (Execute returns IDCANCEL and Error returns
nonzero), a message box is displayed.
190
OWL P ogrammer’ Guider s