CMFCRibbonPanel::SetElementRTCByID

添加通过对功能区面板中提供的运行时选件类信息指定的一个功能区元素。

CMFCRibbonBaseElement* SetElementRTCByID(
    UINT uiCmdID,
    CRuntimeClass* pRTC 
);

参数

  • [in] uiCmdID
    指定功能区元素的命令ID添加。

  • [in] [out] pRTC
    对运行时选件类信息的指针与已添加到功能区面板功能区组件。

返回值

使用指定的运行时选件类信息,创建的功能区元素。

备注

如果要添加自定义元素(例如,颜色按钮)添加到功能区面板,您必须指定自定义组件的运行时选件类信息。功能区上存储此信息,创建一个自定义组件,并替换指定的命令ID.设置的现有元素然后返回指向该新创建的元素。

示例

下面的示例演示如何使用 SetElementRTCByID 方法:

// Load and add toolbar with standard buttons. This toolbar
// should display a custom color button with id ID_CHAR_COLOR:

pPanel->AddToolBar(IDR_MAINFRAME, IDB_MAINFRAME256);
CMFCRibbonColorButton* pColorButton =
    (CMFCRibbonColorButton*)pPanel->SetElementRTCByID(
    ID_CHAR_COLOR, RUNTIME_CLASS (CMFCRibbonColorButton));

// SetElementRTCByID sets runtime class and returns a pointer
// to the newly created custom button, which can be set up immediately:
pColorButton->EnableAutomaticButton(_T("Automatic"), RGB (0, 0, 0));

要求

标头: afxRibbonPanel.h

请参见

参考

CMFCRibbonPanel选件类

层次结构图