ReplaceCategoryByXML

Description

Replaces an existing category with the category from an XML file.

Applies to

RibbonBar control

Syntax

Integer controlname.ReplaceCategoryByXML ( long itemhandle, string data )

Argument

Description

controlname

The name of the RibbonBar control.

ItemHandle The handle for the item for which you want to replace category.
data The string of the category data in the required RibbonBar XML format. To ensure the format is correct, you can export the menu to an XML file and then modify the file according to your needs.

Return value

Integer.

1 - Successful.

-1 - An internal error occurs.

-2 - The library fails to load.

-5 - Any of the following: 1) XML syntax error; 2) XML encode error; 3) XML data is null.

If any argument's value is null, returns null.

Examples

An example of XML file:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<RibbonBar>
 <RibbonItems>
  <Categories>
   <Category Enabled="true" MenuItemName="m_edit" StatusbarText="Edit_replace2" Tag="Edit" Text="Edit_replace2" Visible="true">
         <Panel Enabled="true" PictureName="RibbonMenuButtonLarge!" Text="Undo_replace2" Visible="true">
           <SmallButton Checked="false" DefaultCommand="false" Enabled="false" MenuItemName="m_undo" PictureName="RibbonSmallButtonDefault!" PowerTipText="Undo" Shortcut="Ctrl+Alt+Shift+Z" StatusbarText="Undo last operation" Tag="&lt;Undo>" Text="Undo" Visible="true"/>
         </Panel>
         <Panel Enabled="true" PictureName="RibbonMenuButtonLarge!" Text="Copy" Visible="true">
           <SmallButton Checked="false" DefaultCommand="false" Enabled="false" MenuItemName="m_copy" PictureName="RibbonSmallButtonDefault!" PowerTipText="Copy" Shortcut="Ctrl+C" StatusbarText="Copy text to clipboard" Text="Copy" Visible="true"/>
           <SmallButton Checked="false" DefaultCommand="false" Enabled="false" MenuItemName="m_paste" PictureName="RibbonSmallButtonDefault!" PowerTipText="Paste" Shortcut="Ctrl+V" StatusbarText="Paste text from clipboard" Text="Paste" Visible="true"/>
           <SmallButton Checked="false" DefaultCommand="false" Enabled="false" MenuItemName="m_clear" PictureName="RibbonSmallButtonDefault!" PowerTipText="Clear" StatusbarText="Clear text" Text="Clear" Visible="true"/>
           <SmallButton Checked="false" DefaultCommand="false" Enabled="false" MenuItemName="m_cut" PictureName="RibbonSmallButtonDefault!" PowerTipText="Cut" Shortcut="Ctrl+X" StatusbarText="Cut text to clipboard" Text="Cut" Visible="true"/>
         </Panel>
       </Category>
  </Categories>
 </RibbonItems>
</RibbonBar>

An example of calling ReplaceCategoryByXML in scripts:

RibbonCategoryItem  lr_Category
Integer             li_Return
String              ls_tag, ls_xml

ls_tag ="Edit"
li_Return = mdirbb_1.getitembytag(ls_tag, lr_Category)
If li_Return = 1 Then
 li_Return = mdirbb_1.replacecategorybyxml(lr_Category.itemhandle, ls_xml)
End If