CMFCPropertyGridColorProperty Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CMFCPropertyGridColorProperty Class.

The CMFCPropertyGridColorProperty class supports a property list control item that opens a color selection dialog box.

Syntax

class CMFCPropertyGridColorProperty : public CMFCPropertyGridProperty  

Members

Public Constructors

Name Description
CMFCPropertyGridColorProperty::CMFCPropertyGridColorProperty Constructs a CMFCPropertyGridColorProperty object.
CMFCPropertyGridColorProperty::~CMFCPropertyGridColorProperty Destructor.

Public Methods

Name Description
CMFCPropertyGridColorProperty::EnableAutomaticButton Enables the automatic button on the color selection dialog box. (The standard automatic button is labeled Automatic.)
CMFCPropertyGridColorProperty::EnableOtherButton Enables the other button on the color selection dialog box. (The standard other button is labeled More Colors….)
CMFCPropertyGridColorProperty::FormatProperty Formats the text representation of a property value. (Overrides CMFCPropertyGridProperty::FormatProperty.)
CMFCPropertyGridColorProperty::GetColor Gets the current color of the property.
CMFCPropertyGridColorProperty::GetThisClass Used by the framework to obtain a pointer to the CRuntimeClass object that is associated with this class type.
CMFCPropertyGridColorProperty::OnClickButton Called by the framework when the user clicks a button that is contained in a property. (Overrides CMFCPropertyGridProperty::OnClickButton.)
CMFCPropertyGridColorProperty::OnDrawValue Called by the framework to display the property value. (Overrides CMFCPropertyGridProperty::OnDrawValue.)
CMFCPropertyGridColorProperty::OnEdit Called by the framework when the user is about to modify a property value. (Overrides CMFCPropertyGridProperty::OnEdit.)
CMFCPropertyGridColorProperty::OnUpdateValue Called by the framework when the value of an editable property has changed. (Overrides CMFCPropertyGridProperty::OnUpdateValue.)
CMFCPropertyGridColorProperty::SetColor Sets a new color for the property.
CMFCPropertyGridColorProperty::SetColumnsNumber Specifies the number of columns in the current color property grid.
CMFCPropertyGridColorProperty::SetOriginalValue Sets the original value of an editable property.

Remarks

The CMFCPropertyGridColorProperty class supports a color property that can be added to a property list control. For more information, see the CMFCPropertyGridCtrl Class.

Example

The following example demonstrates how to construct an object of the CMFCPropertyGridColorProperty class and configure this object by using various methods of the CMFCPropertyGridColorProperty class. The code explains how to enable the automatic and other buttons, and how to set the color and the columns number. This example is part of the New Controls sample.

  CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("Window Color"), RGB(210, 192, 254), NULL, _T("Specifies the default dialog color"));
    pColorProp->EnableOtherButton(_T("Other..."));
    pColorProp->EnableAutomaticButton(_T("Default"), ::GetSysColor(COLOR_3DFACE));
    pColorProp->SetColor(RGB(255,0,0));
    pColorProp->SetColumnsNumber(3);

Inheritance Hierarchy

CObject

CMFCPropertyGridProperty

CMFCPropertyGridColorProperty

Requirements

Header: afxpropertygridctrl.h

CMFCPropertyGridColorProperty::CMFCPropertyGridColorProperty

Constructs a CMFCPropertyGridColorProperty object.

CMFCPropertyGridColorProperty(
    const CString& strName,  
    const COLORREF& color,  
    CPalette* pPalette = NULL,  
    LPCTSTR lpszDescr = NULL,  
    DWORD_PTR dwData = 0);

Parameters

[in] strName
The name of the property.

[in] color
The color value of the property.

[in] pPalette
Pointer to a palette of colors. The default value is NULL.

[in] lpszDescr
The property description. The default value is NULL.

[in] dwData
Application-specific data, such as an integer or a pointer to other data that is associated with the property. The default value is 0.

CMFCPropertyGridColorProperty::EnableAutomaticButton

Enables the automatic button on the color selection dialog box. (The standard automatic button is labeled Automatic.)

void EnableAutomaticButton(
    LPCTSTR lpszLabel,  
    COLORREF colorAutomatic,  
    BOOL bEnable=TRUE);

Parameters

[in] lpszLabel
The label text of the automatic button.

[in] colorAutomatic
The RGB color value of the automatic (default) color.

[in] bEnable
TRUE to enable the automatic button; otherwise, FALSE. The default value is TRUE.

Remarks

CMFCPropertyGridColorProperty::EnableOtherButton

Enables the other button on the color selection dialog box. (The standard other button is labeled More Colors….)

void EnableOtherButton(
    LPCTSTR lpszLabel,  
    BOOL bAltColorDlg=TRUE,  
    BOOL bEnable=TRUE);

Parameters

[in] lpszLabel
The label text of the other button.

[in] bAltColorDlg
TRUE to display the CMFCColorDialog dialog box; FALSE to display the standard color selection dialog box. The default value is TRUE.

[in] bEnable
TRUE to display the other button; otherwise, FALSE. The default value is TRUE.

Remarks

CMFCPropertyGridColorProperty::GetColor

Gets the current color of the property.

COLORREF GetColor() const;  

Return Value

An RGB color value.

Remarks

CMFCPropertyGridColorProperty::SetColor

Sets a new color for the property.

void SetColor(COLORREF color);

Parameters

[in] color
An RGB color value.

Remarks

CMFCPropertyGridColorProperty::SetColumnsNumber

Specifies the number of columns in the current color property grid.

void SetColumnsNumber(int nColumnsNumber);

Parameters

[in] nColumnsNumber
The preferred number of columns in the color property grid.

Remarks

This method sets the value of the m_nColumnsNumber protected data member.

CMFCPropertyGridColorProperty::SetOriginalValue

Sets the original value of an editable property.

virtual void SetOriginalValue(const COleVariant& varValue);

Parameters

[in] varValue
A value.

Remarks

Use the CMFCPropertyGridProperty::ResetOriginalValue method to reset the original value of an edited property.

See Also

Hierarchy Chart
Classes
CMFCPropertyGridCtrl Class
CMFCPropertyGridProperty Class