BCGControlBar Pro for MFC
CBCGPBaseRibbonElement* CBCGPRibbonPanel::SetElementRTCByID ( UINT  uiCmdID,
CRuntimeClass *  pRTC 
)

Specifies a runtime class of element with given command ID.

Returns
A pointer to custom element, created using the specified runtime class information.

Ribbon Control creates and copies elements on the fly. If you need to add a custom element (for example, a color button), you need to specify the custom element's runtime class info. Ribbon Control will store this information, create the custom element and replace an existing element with specified command ID. Then it returns a pointer to the newly created element and you can set it up immediately.

Copy
// 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);
CBCGPRibbonColorButton* pColorButton = (CBCGPRibbonColorButton*)pPanel->SetElementRTCByID(ID_CHAR_COLOR, RUNTIME_CLASS(CBCGPRibbonColorButton));

SetElementRTCByID sets runtime class and returns a pointer to the newly created custom button, which can be set up immediately:

Copy
pColorButton->EnableAutomaticButton(_T("Automatic"), RGB(0, 0, 0));
Parameters
uiCmdIDSpecifies command ID.
pRTCSpecifies runtime class information.