11.04.2014 Views

Advanced MFC Programming

Advanced MFC Programming

Advanced MFC Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 7. Common Dialog Boxes<br />

7.5 Color Dialog Box<br />

Introduction<br />

A color dialog box lets the user choose one or several colors from a pool of available colors. In<br />

Windows, a valid color may be formed by combining red, green and blue colors with different intensities.<br />

There are altogether 16,777,216 possible colors in the system.<br />

In <strong>MFC</strong>, color dialog box is supported by class CColorDialog. To create a color dialog box, we need to<br />

use class CColorDialog to declare a variable, then call CColorDialog::DoModal() to activate the dialog<br />

box.<br />

In the color dialog box, there are four ways to choose a color (Figure 7-5):<br />

1) Select a color from those listed as Basic colors.<br />

1) Select a color from those listed as Custom colors.<br />

1) Select a color from “color matrix”.<br />

1) Input R, G, B values directly.<br />

The selected color is shown in “Color | Solid” window. When a dialog box is implemented, there are<br />

two things that we can customize: the original selected color and the custom colors. If we do not change<br />

anything, Tc - can customize can p9 r TD 2ck<br />

184

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!