Adds new controls to existing groups and other control containers.

Syntax

Error = Send_Message(Ctrl, "OLE.AddControls", Xml)

Parameters

PropertyDescription
XmlThe XML snippet used to add controls.

Returns

An XML parsing error, or "" if the XML parsed successfully. (Added in 4.1.20)

Remarks

The AddControls method allows you to add new controls to the ribbon at runtime. This is the only way to add new controls. Do not call Init multiple times.

To use this method, pass a string containing XML. It does not matter where the XML was originally stored. All that matters is that the one parameter you pass contains XML with one <AddControls> element. Each XML element is documented on the wiki, but you'll want to start with the <AddControls> element and work your way down.

Example

In the following example, we are adding a Find button to four different places: a group whose key is "EDITING", the Quick Access toolbar, the Tab Bar area, and to a Split Button's sub-menu dropdown. Note how we define the button's command the first time, then simply reference the command in all the other buttons. Thus, no matter which button the user clicks, the same event fires. All four buttons need to have a unique Key, even though they can share the same command.

Xml  = ''
Xml := '<AddControls>'
Xml := '  <Group Key="EDITING">'
Xml := '    <Button Key="BTN_FIND">'
Xml := '      <Command Key="FIND" Caption="Find" SmallIcon="Icons\find.png" />'
Xml := '    </Button>'
Xml := '  </Group>'
Xml := '  <QuickAccessControls>'
Xml := '    <Button Key="QA_BTN_FIND" Command="FIND" />'
Xml := '  </QuickAccessControls>'
Xml := '  <TabBarControls>'
Xml := '    <Button Key="TB_BTN_FIND" Command="FIND" />'
Xml := '  </TabBarControls>'
Xml := '  <SplitButton Key="MY_SPLIT_BUTTON">'
Xml := '    <Button Key="SPL_BTN_FIND" Command="FIND" />'
Xml := '  </SplitButton>'
Xml := '</AddControls>'

Send_Message(@Window:".OLE_RIBBON", "OLE.AddControls", Xml)

See Also

RemoveControls<AddControls>

  • No labels