on 2006 Jan 07 7:22 AM
Hi
All How Can Add a new Folder In A Miain Menu and We Wana Be Add Thre Menu Item With In This Folder Plz Help Me
Thanks
sha
Hi sha,
If you want to create menus and sub-menus then the best method is to use XML files and the LoadBatchActions method of the SBO application object.
For example, to create a menu folder and 3 menu items, I write the following routine (in c#):
private void AddUserMenu()
{
SAPbouiCOM.Form oForm;
XmlDocument oXML;
string sFilename = "";
// Get reference to the Main Menu form
oForm = m_sboApp.Forms.GetFormByTypeAndCount(169, 1);
// Freeze it (to stop the annoying flickering!)
oForm.Freeze(true);
// Load the menus to the SBO application in one batch
oXML = new XmlDocument();
oXML.Load(System.Environment.CurrentDirectory.ToString() + "
Menus
MYMENU.xml");
sFilename = oXML.InnerXml.ToString();
m_sboApp.LoadBatchActions(ref sFilename);
// Unfreeze the Main Menu form
oForm.Freeze(false);
}
I then create an XML file for the menus which I place in the appropriate directory (in my example this is in a subfolder to the addon executable called Menus):
<Application>
<Menus>
<action type="add">
<Menu Checked="0" Enabled="1" FatherUID="43520" String="MYMENU" Type="2" UniqueID="MYMENU01" Image="">
<Menus>
<action type="add">
<Menu Checked="0" Enabled="1" FatherUID="MYMENU01" String="Submenu 1" Type="1" UniqueID="MYMENU02" />
<Menu Checked="0" Enabled="1" FatherUID="MYMENU01" String="Submenu 2" Type="1" UniqueID="MYMENU03" />
<Menu Checked="0" Enabled="1" FatherUID="MYMENU01" String="Submenu 3" Type="1" UniqueID="MYMENU04" />
</action>
</Menus>
</Menu>
</action>
</Menus>
</Application>
You then call the function AddUserMenu in your addon during startup.
Hope this helps,
Owen
P.S. I also recommend you create another routine to remove your menu if the addon is stopped by the user (via addon administrator) or if you need to cater for language changes. The removal process is very similar (ie you call LoadBatchActions) but the XML is different. See the UI Reference in the SDK for more details.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
105 | |
8 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.