cancel
Showing results for 
Search instead for 
Did you mean: 

Include Menu items in "Main Menu"

Former Member
0 Kudos

Hi,

I'm adding new menu options in "Main menu" when the application is starting, but the screen shown the refresh of this action being so horrible to the look of users.

To avoid this I try to Freeze the form (169,1) before the add, but the menu items don't appear, anybody know how can i add menu items without showing the refresh.

Thanks!

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks for your help Owen!!!

My problem was that i didn't use the instruction "Form.Update"

former_member201110
Active Contributor
0 Kudos

Hi Mariano,

The easiest way to load menus is to freeze the main menu and load all menus from XML. Here's a C# example:


private void AddMenus()
{ 
    XmlDocument oXML;
    string sXML = "";

    // Get reference to the Main Menu form
    SAPbouiCOM.Form sboForm = _sboApp.Forms.GetFormByTypeAndCount(169, 1);

    // Freeze it
    sboForm.Freeze(true);

    try
    {
        // Load the menus to the SBO application in one batch
        oXML = new XmlDocument();
        oXML.Load(System.Environment.CurrentDirectory.ToString() + "\\Menus\\" + MENU_FILE);

        sXML = oXML.InnerXml.ToString();
        _sboApp.LoadBatchActions(ref sXML);

    }
    finally
    {
        // Unfreeze and update the Main Menu form
        sboForm.Freeze(false);
        sboForm.Update();
    }
}

And here's an example XML file:


<Application>
  <Menus>
    <action type="add">
      <Menu Checked="0" Enabled="1" FatherUID="8192" String="My Popup Menu" Type="2" UniqueID="MYMENU1" Image="">
        <Menus>
          <action type="add">
            <Menu Checked="0" Enabled="1" FatherUID="MYMENU1" String="My Submenu 1" Type="1" UniqueID="MYSUBMENU1"/>
            <Menu Checked="0" Enabled="1" FatherUID="MYMENU1" String="My Submenu 2" Type="1" UniqueID="MYSUBMENU2"/>
          </action>
        </Menus>
      </Menu>
      <Menu Checked="0" Enabled="1" FatherUID="2304" String="My Standard Menu" Type="1" Position="4" UniqueID="MYMENU2"/>
    </action>
  </Menus>
</Application>

Kind Regards,

Owen