OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Constructing common dialog boxes

Each common dialog box class has a nested class called TData that contains some common housekeeping members and data specific to each type of common dialog box.

For example, TChooseColorDialog::TData has members for the color being chosen and an array for a set of custom colors. The following table lists the two members common to all TData nested classes.

NameTypeDescription
Flagsuint32A set of common dialog box-specific flags that control the appearance and behavior of the dialog box. For example, CC_SHOWHELP is a flag that tells the color selection common dialog box to display a Help button the user can press to get context-sensitive Help.
Erroruint32An error code used if an error occurred while processing a common dialog box; zero if no error occurred. Because Execute returns IDCANCEL both when the user chose Cancel and when an error occurred, you must 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's TData nested class, and optional parameters for a custom dialog box template, title string, and module pointer.

Here is a sample fragment that constructs a common color selection dialog 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.Color = TColor::Black;
if (TChooseColorDialog(this, colors).Execute() == IDOK)
SetColor(colors.Color);

After 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.

See Also