Skip to Content
avatar image
Former Member

Include Menu items in "Main Menu"

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!

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Oct 15, 2008 at 07:47 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 15, 2008 at 08:03 PM

    Thanks for your help Owen!!!

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

    Add comment
    10|10000 characters needed characters exceeded