
Table 8.2: Common dialog box TData members (continued)
___________________________________________________________________________
Error
DWORD This is an error code if an error occurred while processing a common
dialog box; it’ zero if no error occurred.
Execute
returns IDCANCELs
both when the user chose Cancel and when an error occurred, so you
should check
Error
to determine whether an error actually occurred.
____________________________________________________________________
Each common dialog box class has a constructor that takes a pointer to a
parent window object, a reference to that class’ TData nested class, and
optional parameters for a custom dialog box template, title string, and
module pointer.
Here’ a sample fragment that constructs a common color selection dialogs
box:
TChooseColorDialog::TData colors;
static TColor custColors[16] =
{
0x010101L, 0x101010L, 0x202020L, 0x303030L,
0x404040L, 0x505050L, 0x606060L, 0x707070L,
0x808080L, 0x909090L, 0xA0A0A0L, 0xB0B0B0L,
0xC0C0C0L, 0xD0D0D0L, 0xE0E0E0L, 0xF0F0F0L
};
colors.CustColors = custColors;
colors.Flags = CC_RGBINIT;
colors.Color = TColor::Black;
if (TChooseColorDialog(this, colors).Execute() == IDOK)
SetColor(colors.Color);
Once the user has chosen a new color in the dialog box and pressed OK,
that color is placed in the Color member of the TData object.
Once you’ e constructed the common dialog box object, you should executev
Executing common
it (for a modal dialog box) or create it (for a modeless dialog box). The
dialog boxes
following table lists whether each type of common dialog box must be
modal or modeless.
__________________________________________________________________________
T pe Modal or modeless Run by callingy
____________________________________________________________________
Color Modal
Execute
Font Modal
Execute
File open Modal
Execute
File save Modal
Execute
Find Modeless
Create
Find/replace Modeless
Create
P inter Modal
Execute
r
____________________________________________________________________
Chapter 8, Dialog box objects
187