Share via


CMFCColorDialog Class

The CMFCColorDialog class represents a color selection dialog box.

class CMFCColorDialog : public CDialogEx

Members

Public Constructors

Name

Description

CMFCColorDialog::CMFCColorDialog

Constructs a CMFCColorDialog object.

CMFCColorDialog::~CMFCColorDialog

Destructor.

Public Methods

Name

Description

CMFCColorDialog::GetColor

Returns the current selected color.

CMFCColorDialog::GetPalette

Returns the color's palette.

CMFCColorDialog::PreTranslateMessage

Translates window messages before they are dispatched to the TranslateMessage and DispatchMessage Windows functions. For syntax and more information, see CWnd::PreTranslateMessage. (Overrides CDialogEx::PreTranslateMessage.)

CMFCColorDialog::RebuildPalette

Derives a palette from the system palette.

CMFCColorDialog::SetCurrentColor

Sets the current selected color.

CMFCColorDialog::SetNewColor

Sets the color most equivalent to a specified RGB value.

CMFCColorDialog::SetPageOne

Selects an RGB value for the first property page.

CMFCColorDialog::SetPageTwo

Selects an RGB value for the second property page.

Protected Data Members

Name

Description

m_bIsMyPalette

TRUE if the color selection dialog box uses its own color palette, or FALSE if the dialog box uses a palette that is specified in the CMFCColorDialog constructor.

m_bPickerMode

TRUE while the user is selecting a color from the selection dialog box; otherwise, FALSE.

m_btnColorSelect

The color button that the user has selected.

m_CurrentColor

The currently selected color.

m_hcurPicker

The cursor that is used to pick a color.

m_NewColor

The prospective selected color, which can be permanently selected or reverted to the original color.

m_pColourSheetOne

A pointer to the first property page of the color selection property sheet.

m_pColourSheetTwo

A pointer to the second property page of the color selection property sheet.

m_pPalette

The current logical palette.

m_pPropSheet

A pointer to the property sheet for the color selection dialog box.

m_wndColors

A color picker control object.

m_wndStaticPlaceHolder

A static control that is a placeholder for the color picker property sheet.

Remarks

The color selection dialog box is displayed as a property sheet with two pages. On the first page, you select a standard color from the system palette; on the second page, you select a custom color.

You can construct a CMFCColorDialog object on the stack and then call DoModal, passing the initial color as a parameter to the CMFCColorDialog constructor. The color selection dialog box then creates several CMFCColorPickerCtrl Class objects to handle each color palette.

Inheritance Hierarchy

CObject

   CCmdTarget

      CWnd

         CDialog

            CDialogEx

               CMFCColorDialog

Example

The following example demonstrates how to configure a color dialog by using various methods in the CMFCColorDialog class. The example shows how to set the current and the new colors of the dialog, and how to set the red, green, and blue components of a selected color on the two property pages of the color dialog. This example is part of the New Controls sample.

// COLORREF m_Color
    CMFCColorDialog dlg(m_Color, 0, this);
    dlg.SetCurrentColor(RGB(0,255,0));
    dlg.SetNewColor(RGB(0,0,255));
    // set the red, green, and blue components of a selected 
    // color on the two property pages of the color dialog
    dlg.SetPageOne(255,0,0);
    dlg.SetPageTwo(0,255,0);

Requirements

Header: afxcolordialog.h

See Also

Reference

Hierarchy Chart

CMFCColorPickerCtrl Class

Other Resources

MFC Classes