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

The color common dialog box lets you choose and create colors for use in your application.

For example, a paint application might use the color common dialog box to choose the color of a paint bucket.

TChooseColorDialog::TData has several members you must initialize before constructing the dialog box object:

TData memberTypeDescription
ColorTColorThe selected color. When you execute the dialog box, Color specifies the default color. When the user closes the dialog box, Color specifies the color the user chose.
CustColorsTColor*A pointer to an array of sixteen custom colors. On input, it specifies the default custom colors. On output, it specifies the custom colors the user chose.

In the following example, a color common dialog box is used to set the window object's Color member, which is used elsewhere to paint the window. Note the use of the TWindow::Invalidate() member function to force the window to be repainted in the new color.

void TCommDlgWnd::CmColor()
{
// use static to keep custom colors around between
// executions of the color common dialog box
static TColor custColors[16];
TChooseColorDialog::TData choose;
choose.Flags = CC_RGBINIT;
choose.Color = Color;
choose.CustColors = custColors;
if(TChooseColorDialog(this, choose).Execute() == IDOK)
Color = choose.Color;
Invalidate();
}

See Also