Color Well Control
The Objective Toolkit Color Well classes provide a sophisticated Color Selection control. This control displays the 20-system colors in a five by four grid.
Figure 19 – Color Well Control
Figure 20 – Color Well Control with Other Button
The user can select a color by clicking a cell in the grid. The user can select from a wider range of colors by clicking the Other button.
Figure 21 – Common Color Selection Dialog
The hierarchy diagram for the Objective Toolkit color well classes is as follows:
Figure 22 – Objective Toolkit Color Well Class Hierarchy
The SECColorWell class is a CWnd derivative designed for embedding in a dialog window or a CFormView. The color well automatically sizes to fit its content, and it can have a 3D-raised border. SECColorWell also supports palette realization of the selected color. In other words, it maps entries from the current logical palette to the system palette.
The SECColorWell sends a CWN_COLOR_CHANGE message to its parent window when a new color is selected.
Using SECColorWell
To incorporate SECColorWell into your code:
1. Create the SECColorWell window using the Create() method. Remember to specify whether the control should have an Other button. If you want to embed the color well in a dialog, specify the initial x and y coordinates in dialog base units.
2. Set the initially selected color with the SetColor() method.
3. Enable or disable palette realization of the colors before drawing with the SetPaletteRealization() method.
4. Enable or disable the ability to select a color by passing the mouse over a cell with the SetMouseTracking() method.
5. Call GetColor() to obtain the currently selected color.
6. After you create the SECColorWell window, you can use the DDX_Color() function as part of a DoDataExchange() method.
Customizing SECColorWell
You can customize the SECColorWell class with the following virtual methods:
Table 8 – Virtual Methods for SECColorWell 
Override to customize the drawing of an unselected cell.
Override to customize the drawing of a selected cell.
Override to change the size of the grid. Set the m_nCols and m_nRows member variables.
Override in conjunction with SetGridSize() to initialize any extra color cells defined in the grid.
Override to define whether the color well has a focus rectangle, an extra 1-pixel-wide border drawn around the edge of the window, when it has focus.
Override to specify the flags with which the common color selection dialog is opened when the Other button is clicked.
The SECPopupColorWell class works with the SECWellButton class. It provides a pop-up color selection window. After the application creates the window, it self-destructs when it loses focus or a color is selected.
When the user selects a new color or clicks the Other button, the SECWellButton sends CWN_COLOR_CHANGE and CWN_CUSTOM_COLOR messages to a specified window.
To incorporate SECPopupColorWell into your code
1. Create the pop-up color well using the Create() method.
2. Set the window to receive color change notifications using the SetNotifyWindow() method.
3. Set any other required options as you would for an SECColorWell window.
ColorWell Sample
The use of SECColorWell and SECPopupColorWell is demonstrated in the Objective Toolkit COLOR sample, located at Samples\Toolkit\MFC\Controls\colrwell. This sample is not shipped with the product. For information on how to obtain this sample, see “Location of Sample Code” in the Getting Started part.