You can export the menu into an XML file in the following way:
-
If you right-click the top-level menu object and then select Export to RibbonBar XML, the entire menu will be exported as a ribbon bar in the XML format.
This XML file (or string) can be loaded by the ImportFromXMLFile (or ImportXML) function.
Note
It is unsupported to export a menu that is created dynamically at runtime.
It is unsupported to export the toolbar, therefore the XML file will not include the QuickAccessToolbar.
The export rules are the same as the RibbonView rules.
-
If you right-click the 1st-level menu item and then select Export to RibbonBar XML, that menu item (including its sub-menus) will be exported as a ribbon category in the XML format.
This file can be loaded by the ReplaceCategoryByXML function.
Note
It is unsupported to export the 2nd-level, 3rd-level, or 4th-level menu item only to the XML file.
After you export the menu to the XML file, you can customize the file in the RibbonBar Builder and then load this customized ribbon bar via the ImportFromXMLFile or ImportXML function.
Here are complete steps for how to do that:
-
Export the menu to an XML file by right-clicking the menu object or the 1st-level menu item in the menu treeview, and then selecting Export To RibbonBar XML.
-
Open the RibbonBar Builder by selecting the Tools > RibbonBar Builder menu from the PowerBuilder IDE, and then load the exported XML file to the RibbonBar Builder by selecting the Open File menu.
-
In the RibbonBar Builder, customize the ribbon bar by changing the contents of the XML file and previewing the result. Save the XML file or as an XML string when finishing customization.
The ribbon items: category, panel, large button, small button, and ribbon menu exported from the menu are automatically mapped and bound to the corresponding standard ribbon item controls: RibbonCategoryItem, RibbonPanelItem, RibbonLargeButton, RibbonSmallButton, and RibbonMenuItem.
You can customize and control the ribbon items through the properties, events, and functions of these controls.
Note
During the manual modification of XML, ensure that the original MenuItemName values are not altered. Otherwise, the mapping relationship will be broken, leading to the inability to trigger the corresponding events for the MenuItem when the relevant button is clicked.
-
Load the XML file or string via the ImportFromXMLFile, ImportXML or ReplaceCategoryByXML function in the MenuChanged event of the MDI window.
Code example 1:
li_rtn = mdirbb_1.ImportFromXMLFile ("Export2.xml")
Code example 2:
li_rtn = mdirbb_1.importxml(ls_xml)
Code example 3:
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
Note
In order for the MenuChanged event to be triggered successfully, the DisplayMenuAsRibbonBar property must be enabled.
The mdirbb_1 object represents the ribbon bar displayed or converted from the menu. For more information about mdirbb_1, refer to the next section.