共用方式為


CMFCRibbonColorButton 類別

CMFCRibbonColorButton 類別實作可以加入功能區列中的色彩按鈕。 功能區色彩按鈕會顯示包含一個或多個色板的下拉式功能表。

語法

class CMFCRibbonColorButton : public CMFCRibbonGallery

成員

公用建構函式

名稱 描述
CMFCRibbonColorButton::CMFCRibbonColorButton

公用方法

名稱 描述
CMFCRibbonColorButton::AddColorsGroup 將色彩群組加入標準色彩區域中。
CMFCRibbonColorButton::EnableAutomaticButton 指定是否啟用 [自動] 按鈕。
CMFCRibbonColorButton::EnableOtherButton 啟用 [其他] 按鈕。
CMFCRibbonColorButton::GetAutomaticColor
CMFCRibbonColorButton::GetColor 傳回目前選取的色彩。
CMFCRibbonColorButton::GetColorBoxSize 傳回色軸顯示的色彩項目大小。
CMFCRibbonColorButton::GetColumns
CMFCRibbonColorButton::GetHighlightedColor 傳回目前所選項目在快顯調色盤上的色彩。
CMFCRibbonColorButton::RemoveAllColorGroups 從標準色彩區域移除所有色彩群組。
CMFCRibbonColorButton::SetColor 從標準色彩區域選取色彩。
CMFCRibbonColorButton::SetColorBoxSize 設定色軸顯示之所有色彩項目的大小。
CMFCRibbonColorButton::SetColorName
CMFCRibbonColorButton::SetColumns
CMFCRibbonColorButton::SetDocumentColors 指定文件色彩區域顯示的 RGB 值清單。
CMFCRibbonColorButton::SetPalette
CMFCRibbonColorButton::UpdateColor

備註

當使用者按下它時,功能區色彩按鈕就會顯示色軸。 這個色軸預設包含色彩選取範圍的調色盤,稱為標準色彩區域。 色軸也可以選擇顯示 [自動] 按鈕,讓使用者選取預設的色彩,而 [其他] 按鈕則顯示包含其他色彩的快顯調色盤。

範例

下例示範如何在 CMFCRibbonColorButton 類別中使用各種方法。 此範例示範如何建構 CMFCRibbonColorButton 物件、設定大型影像、啟用 [自動] 按鈕、啟用 [其他] 按鈕、設定資料行數目、設定色軸顯示的所有色彩項目大小、將色彩群組加入標準色彩區域中,以及指定文件色彩區域顯示的 RGB 值清單。 這段程式碼片段是 Draw 用戶端範例的一部分。

// 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);

繼承階層架構

CObject

CMFCRibbonBaseElement

CMFCRibbonButton

CMFCRibbonGallery

CMFCRibbonColorButton

需求

標題: afxribboncolorbutton.h

CMFCRibbonColorButton::AddColorsGroup

將色彩群組加入標準色彩區域中。

void AddColorsGroup(
    LPCTSTR lpszName,
    const CList<COLORREF,COLORREF>& lstColors,
    BOOL bContiguousColumns=FALSE);

參數

lpszName
[in]組名。

lstColors
[in]色彩清單。

bContiguousColumns
[in]控制色彩專案在群組中的顯示方式。 如果為 TRUE,則會繪製沒有垂直間距的色彩專案。 如果為 FALSE,則會使用垂直間距繪製色彩專案。

備註

使用此函式讓色彩快顯顯示陣列色彩。 您可以控制色彩在群組中的顯示方式。

CMFCRibbonColorButton::CMFCRibbonColorButton

建構 CMFCRibbonColorButton 物件。

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]指定當使用者按一下按鈕時所要執行的命令識別碼。

lpszText
[in]指定要出現在按鈕上的文字。

nSmallImageIndex
[in]要出現在按鈕上之小型影像之以零起始的索引。

color
[in]按鈕的色彩(預設為黑色)。

bSimpleButtonLook
[in]如果為 TRUE,則會將按鈕繪製為簡單的矩形。

nLargeImageIndex
[in]要出現在按鈕上之大型影像之以零起始的索引。

傳回值

備註

CMFCRibbonColorButton::EnableAutomaticButton

指定是否啟用 [自動] 按鈕。

void EnableAutomaticButton(
    LPCTSTR lpszLabel,
    COLORREF colorAutomatic,
    BOOL bEnable=TRUE,
    LPCTSTR lpszToolTip=NULL,
    BOOL bOnTop=TRUE,
    BOOL bDrawBorder=FALSE);

參數

lpszLabel
[in][自動] 按鈕的 標籤。

colorAutomatic
[in]指定自動 按鈕預設色彩的 RGB 值

bEnable
[in]如果已啟用 [自動 ] 按鈕,則為 TRUE;如果停用,則為 FALSE。

lpszToolTip
[in][自動 ] 按鈕的工具 提示。

bOnTop
[in]指定 [自動 ] 按鈕是否 在調色盤之前位於頂端。

bDrawBorder
[in]如果應用程式在功能區色彩按鈕的色彩列周圍繪製框線,則為 TRUE。 色彩列會顯示目前選取的色彩。 如果應用程式未繪製框線,則為 FALSE

CMFCRibbonColorButton::EnableOtherButton

啟用 [其他] 按鈕。

void EnableOtherButton(
    LPCTSTR lpszLabel,
    LPCTSTR lpszToolTip=NULL);

參數

lpszLabel
按鈕的標籤。

lpszToolTip
[其他 ] 按鈕的工具提示文字

備註

[ 其他 ] 按鈕是顯示在色彩群組下方的按鈕。 當使用者按一下 [ 其他] 按鈕時,會顯示色彩對話方塊。

CMFCRibbonColorButton::GetAutomaticColor

擷取目前的自動按鈕色彩。

COLORREF GetAutomaticColor() const;

傳回值

代表目前自動按鈕色彩的 RGB 色彩值。

備註

自動按鈕色彩是由 colorAutomatic 傳遞至 方法的參數 CMFCRibbonColorButton::EnableAutomaticButton 所設定。

CMFCRibbonColorButton::GetColor

傳回目前選取的色彩。

COLORREF GetColor() const;

傳回值

按一下按鈕選取的色彩。

CMFCRibbonColorButton::GetColorBoxSize

傳回色軸顯示的色彩項目大小。

CSize GetColorBoxSize() const;

傳回值

下拉式調色盤中色彩按鈕的大小。

CMFCRibbonColorButton::GetColumns

取得功能區色彩按鈕資源庫顯示列中的專案數。

int GetColumns() const;

傳回值

傳回每個資料列中的圖示數目。

備註

CMFCRibbonColorButton::GetHighlightedColor

傳回快顯調色盤上目前選取之元素的色彩。

COLORREF GetHighlightedColor() const;

傳回值

快顯調色盤上目前選取之元素的色彩。

CMFCRibbonColorButton::RemoveAllColorGroups

從標準色彩區域移除所有色彩群組。

void RemoveAllColorGroups();

CMFCRibbonColorButton::SetColor

從標準色彩區域選取色彩。

void SetColor(COLORREF color);

參數

color
[in]要設定的色彩。

CMFCRibbonColorButton::SetColorBoxSize

設定色軸顯示之所有色彩項目的大小。

void SetColorBoxSize(CSize sizeBox);

參數

sizeBox
[in]調色盤中色彩按鈕的新大小。

CMFCRibbonColorButton::SetColorName

設定指定色彩的新名稱。

static void __stdcall SetColorName(
    COLORREF color,
    const CString& strName);

參數

color
[in]色彩的 RGB 值。

strName
[in]指定色彩的新名稱。

備註

因為它會呼叫 CMFCColorBar::SetColorName ,所以這個方法會變更應用程式中所有 CMFCColorBar 物件中指定色彩的名稱。

CMFCRibbonColorButton::SetColumns

設定使用者色彩選取程式期間向使用者呈現之色彩表格中顯示的欄數。

void SetColumns(int nColumns);

參數

nColumns
[in]每個資料列中要顯示的色彩圖示數目。

備註

CMFCRibbonColorButton::SetDocumentColors

指定文件色彩區域顯示的 RGB 值清單。

void SetDocumentColors(
    LPCTSTR lpszLabel,
    CList<COLORREF,COLORREF>& lstColors);

參數

lpszLabel
[in]要與檔色彩一起顯示的文字。

lstColors
[in]RGB 值清單的參考。

CMFCRibbonColorButton::SetPalette

指定要在色彩按鈕顯示之色彩資料表中的標準色彩。

void SetPalette(CPalette* pPalette);

參數

pPalette
[in]調色盤的指標。

備註

CMFCRibbonColorButton::UpdateColor

當使用者從使用者按一下色彩按鈕時所顯示的色彩資料表中選取色彩時,由架構呼叫。

void UpdateColor(COLORREF color);

參數

color
[in]使用者選取的色彩。

備註

方法 CMFCRibbonColorButton::UpdateColor 會變更目前選取的按鈕色彩,並使用BN_CLICKED標準通知傳送WM_COMMAND訊息,以通知其父系。 使用 CMFCRibbonColorButton::GetColor 方法來擷取選取的色彩。

另請參閱

階層架構圖表
類別
CMFCRibbonGallery 類別