description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: CMFCRibbonColorButton Class |
CMFCRibbonColorButton Class |
11/04/2016 |
|
|
6b4b4ee3-8cc0-41b4-a4eb-93e8847008e1 |
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
Name | Description |
---|---|
CMFCRibbonColorButton::CMFCRibbonColorButton |
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.
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.
[!code-cppNVC_MFC_DrawClient#3]
Header: afxribboncolorbutton.h
Adds a group of colors to the regular color area.
void AddColorsGroup(
LPCTSTR lpszName,
const CList<COLORREF,COLORREF>& lstColors,
BOOL bContiguousColumns=FALSE);
lpszName
[in] The group name.
lstColors
[in] The list of colors.
bContiguousColumns
[in] Controls how the color items are displayed in the group. If TRUE, the color items are drawn without a vertical spacing. If FALSE, the color items are drawn with a vertical spacing.
Use this function to make the color pop-up display several groups of colors. You can control how the colors are displayed in group.
Constructs a CMFCRibbonColorButton
object.
CMFCRibbonColorButton();
CMFCRibbonColorButton(
UINT nID,
LPCTSTR lpszText,
int nSmallImageIndex,
COLORREF color = RGB(0, 0, 0));
CMFCRibbonColorButton(
UINT nID,
LPCTSTR lpszText,
BOOL bSimpleButtonLook,
int nSmallImageIndex,
int nLargeImageIndex,
COLORREF color = RGB(0, 0, 0));
nID
[in] Specifies the command ID of the command to execute when a user clicks the button.
lpszText
[in] Specifies the text to appear on the button.
nSmallImageIndex
[in] The zero-based index of the small image to appear on the button.
color
[in] The color of the button (defaults to black).
bSimpleButtonLook
[in] If TRUE, the button is drawn as a simple rectangle.
nLargeImageIndex
[in] The zero-based index of the large image to appear on the button.
Specifies whether the Automatic button is enabled.
void EnableAutomaticButton(
LPCTSTR lpszLabel,
COLORREF colorAutomatic,
BOOL bEnable=TRUE,
LPCTSTR lpszToolTip=NULL,
BOOL bOnTop=TRUE,
BOOL bDrawBorder=FALSE);
lpszLabel
[in] The label for the Automatic button.
colorAutomatic
[in] An RGB value that specifies the Automatic button's default color.
bEnable
[in] TRUE if the Automatic button is enabled; FALSE if it is disabled.
lpszToolTip
[in] The tooltip of the Automatic button.
bOnTop
[in] Specifies whether the Automatic button is at the top, before color palette.
bDrawBorder
[in] TRUE if the application draws a border around the color bar on the ribbon color button. Color bar displays the currently selected color. FALSE if the application does not draw a border
Enables the Other button.
void EnableOtherButton(
LPCTSTR lpszLabel,
LPCTSTR lpszToolTip=NULL);
lpszLabel
The button's label.
lpszToolTip
The tooltip text for the Other button.
The Other button is the button that is displayed below the group of colors. When the user clicks the Other button, it displays a color dialog.
Retrieves the current automatic-button color.
COLORREF GetAutomaticColor() const;
An RGB color value that represents the current automatic-button color.
The automatic-button color is set by the colorAutomatic
parameter passed to the CMFCRibbonColorButton::EnableAutomaticButton
method.
Returns the currently selected color.
COLORREF GetColor() const;
The color selected by clicking the button.
Returns the size of the color elements that appear on the color bar.
CSize GetColorBoxSize() const;
The size of the color buttons in the drop-down color palette.
Gets the number of items in a row of the ribbon color button's gallery display.
int GetColumns() const;
Returns the number of icons in each row.
Returns the color of the currently selected element on the pop-up color palette.
COLORREF GetHighlightedColor() const;
The color of currently selected element on the pop-up color palette.
Removes all color groups from the regular color area.
void RemoveAllColorGroups();
Selects a color from the regular color area.
void SetColor(COLORREF color);
color
[in] A color to set.
Sets the size of all the color elements that appear on the color bar.
void SetColorBoxSize(CSize sizeBox);
sizeBox
[in] The new size of the color buttons in the color palette.
Sets a new name for a specified color.
static void __stdcall SetColorName(
COLORREF color,
const CString& strName);
color
[in] The RGB value of a color.
strName
[in] The new name for the specified color.
Because it calls CMFCColorBar::SetColorName
, this method changes the name of the specified color in all CMFCColorBar
objects in your application.
Sets the number of columns displayed in the table of colors that is presented to the user during the user's color selection process.
void SetColumns(int nColumns);
nColumns
[in] The number of color icons to display in each row.
Specifies a list of RGB values to display in the document color area.
void SetDocumentColors(
LPCTSTR lpszLabel,
CList<COLORREF,COLORREF>& lstColors);
lpszLabel
[in] The text to be displayed with the document colors.
lstColors
[in] A reference to a list of RGB values.
Specifies the standard colors to display in the color table that the color button displays.
void SetPalette(CPalette* pPalette);
pPalette
[in] A pointer to a color palette.
Called by the framework when the user selects a color from the color table displayed when the user clicks the color button.
void UpdateColor(COLORREF color);
color
[in] A color selected by the user.
The CMFCRibbonColorButton::UpdateColor
method changes the currently selected button's color and notifies its parent by sending a WM_COMMAND message with a BN_CLICKED standard notification. Use the CMFCRibbonColorButton::GetColor method to retrieve the selected color.