Exporting menu to XML file

If you want to further customize the RibbonBar, you can export the menu into a RibbonBar XML file, modify that file in the RibbonBar Builder, and then load it via the ImportFromXMLFile function.

Note

Note that after the menu is exported and customized in the RibbonBar XML file, you will need to maintain the XML file moving forward.

In PowerBuilder IDE, you can export the menu into an XML file in the following way:

  • If you right-click the root node of the menu and select Export to RibbonBar XML, you can export the entire Menu to a RibbonBar in the XML format. Note that this file does not include the QuickAccessToolbar. This file can be used with the ImportFromXMLFile function.

  • If you right-click on the first-level node under the root node and select Export to RibbonBar XML, the MenuItem will be exported to a Ribbon Category in the XML format. This file can be used with the ReplaceCategoryByXML method.

  • Currently, exporting other levels of MenuItem to XML files is not supported.

Note

If the menu is created dynamically at runtime, it cannot be exported to XML.

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 function.

Here are the complete steps for how to do that:

  1. Export the menu to an XML file by right-clicking the menu object in the PowerBuilder system tree, and then selecting Export To RibbonBar XML.

  2. 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.

  3. In the RibbonBar Builder, customize the ribbon bar by changing the scripts in the XML file and previewing the result. Save the XML file when finishing customization.

    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.

  4. Load the XML file via the ImportFromXMLFile function in the MenuChanged event of the MDI window.

    Note

    In order for the MenuChanged event to be triggered successfully, the DisplayMenuAsRibbonBar property must be enabled.