CMFCColorPickerCtrl Class
The CMFCColorPickerCtrl class provides functionality for a control that is used to select colors.
class CMFCColorPickerCtrl : public CButton
Members
Public Constructors
Name |
Description |
---|---|
Constructs a CMFCColorPickerCtrl object. |
Public Methods
Name |
Description |
---|---|
Retrieves the color that the user selects. |
|
Retrieves the hue, luminance and saturation values of the color that the user selects. |
|
Retrieves the hue component of the color that the user selects. |
|
Retrieves the luminance component of the color that the user selects. |
|
Retrieves the saturation component of the color that the user selects. |
|
Sets the current color to the color defined by the specified RGB color components or the specified cell hexagon. |
|
Sets the current color to the specified RGB color value. |
|
Sets the current color to the specified HLS color value. |
|
Changes the hue component of the currently selected color. |
|
Changes the luminance component of the currently selected color. |
|
Sets the width of the luminance bar in the color picker control. |
|
Sets the initial selected color. |
|
Sets the current color palette. |
|
Changes the saturation component of the currently selected color. |
|
Sets the type of color picker control to display. |
Protected Methods
Name |
Description |
---|---|
Called by the framework before a cursor that points to the selected color is displayed. |
Remarks
Standard colors are selected from a hexagonal color palette, and custom colors are selected from a luminance bar where colors are specified using either red/green/blue notation or hue/satuaration/luminance notation.
The following illustration depicts several CMFCColorPickerCtrl objects.
The CMFCColorPickerCtrl supports two pairs of styles. The HEX and HEX_GREYSCALE styles are appropriate for standard color selection. The PICKER and LUMINANCE styles are appropriate for custom color selection.
Perform the following steps to incorporate the CMFCColorPickerCtrl control into your dialog box:
If you use the ClassWizard, insert a new button control into your dialog box template (because the CMFCColorPickerCtrl class is inherited from the CButton class).
Insert a member variable that is associated with the new button control into your dialog box class. Then change the variable type from CButton to CMFCColorPickerCtrl.
Insert the WM_INITDIALOG message handler for the dialog box class. In the handler, set the type, palette, and initial selected color of the CMFCColorPickerCtrl control.
Example
The following example demonstrates how to configure a CMFCColorPickerCtrl object by using various methods in the CMFCColorPickerCtrl class. The example demonstrates how to set the type of the picker control, and how to set its color, hue, luminance, and saturation. The example is part of the New Controls sample.
CMFCColorPickerCtrl m_wndLum;
...
// CPalette m_palSys
// set the type of the color picker control
m_wndLum.SetType(CMFCColorPickerCtrl::LUMINANCE);
m_wndLum.SetPalette(&m_palSys);
// set the color, hue, luminance and saturation of the color picker control
m_wndLum.SetColor(RGB(0, 255, 0));
m_wndLum.SetHue(0.5);
m_wndLum.SetLuminance(2.5);
m_wndLum.SetLuminanceBarWidth(10);
m_wndLum.SetSaturation(0.5);
Inheritance Hierarchy
Requirements
Header: afxcolorpickerctrl.h