CMFCRibbonColorButton Class
The CMFCRibbonColorButton class implements a color button that you can add to a ribbon bar. The ribbon color button displays a drop-down menu that contains one or more color palettes.
class CMFCRibbonColorButton : public CMFCRibbonGallery
Members
Public Constructors
Name |
Description |
---|---|
|
Public Methods
Name |
Description |
---|---|
Adds a group of colors to the regular color area. |
|
Specifies whether the Automatic button is enabled. |
|
Enables the Other button. |
|
|
|
Returns the currently selected color. |
|
Returns the size of the color elements that appear on the color bar. |
|
|
|
Returns the color of the currently selected element on the popup color palette. |
|
Removes all color groups from the regular color area. |
|
Selects a color from the regular color area. |
|
Sets the size of all the color elements that appear on the color bar. |
|
|
|
|
|
Specifies a list of RGB values to display in the document color area. |
|
|
|
|
Remarks
The ribbon color button displays a color bar when a user presses it. By default, this color bar contains a color selection palette called the regular color area. Optionally, the color bar can display an Automatic button, which allows the user to select a default color, and an Other button, which displays a popup color palette that contains additional colors.
Example
The following example demonstrates how to use various methods in the CMFCRibbonColorButton class. The example shows how to construct a CMFCRibbonColorButton object, set the large image, enable the Automatic button, enable the Other button, set the number of columns, set the size of all the color elements that appear on the color bar, add a group of colors to the regular color area, and specify a list of RGB values to display in the document color area. This code snippet is part of the Draw Client sample.
// Create the "Paper Color" button
CMFCRibbonColorButton* pBtnPaperColor = new CMFCRibbonColorButton(ID_VIEW_PAPERCOLOR, _T("Paper Color\ng"), TRUE, 13, 1);
pBtnPaperColor->SetAlwaysLargeImage();
pBtnPaperColor->EnableAutomaticButton(_T("&Automatic"), RGB(255, 255, 255));
pBtnPaperColor->EnableOtherButton(_T("&More Colors..."), _T("More Colors"));
pBtnPaperColor->SetColumns(10);
pBtnPaperColor->SetColorBoxSize(CSize(17, 17));
// CList<COLORREF,COLORREF> m_lstMainColors
pBtnPaperColor->AddColorsGroup(_T("Theme Colors"), m_lstMainColors, TRUE);
// CList<COLORREF,COLORREF> m_lstAdditionalColors
pBtnPaperColor->AddColorsGroup(_T(""), m_lstAdditionalColors, FALSE);
// CList<COLORREF,COLORREF> m_lstStandardColors
pBtnPaperColor->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors, TRUE);
CList<COLORREF,COLORREF> lstColors;
lstColors.AddTail(RGB(255,0,0));
lstColors.AddTail(RGB(0,255,0));
lstColors.AddTail(RGB(0,0,255));
pBtnPaperColor->SetDocumentColors( _T("Document Colors"), lstColors );
Inheritance Hierarchy
Requirements
Header: afxribboncolorbutton.h