I am new to SAP Addon development and I am trying to build a few forms in C#, but I have a little problem with how I should load a Form and register menus.
Should an addon leave the buttons, menus it registered after shutting down the addon's executable? I develop in Visual Studio and when I start my addon, it first registers the menu elements, then the event handlers (these event handlers look for my menus to be pressed, then start a new form). If I shutdown the exe, the menus are still there and I think the forms too, even tough they are closed in SAP (If I restart the addon the menus are working again, but changes most of the time don't show without an SAP relog/restart). If I restart the SAP a menus disappear of course.
1. I create an SAPboui.Application, passed down it as parameter for the following methods
2. Register App Events
3. Register Menu Elements
( oCreationPackage = ((MenuCreationParams (SBOApp.CreateObject(BoCreatableObjectType.cot_MenuCreationParams))); .. )
4. Register Menu Event Handler
5. The menu event handler looks like this:
public void Listener(ref MenuEvent pVal, out bool BubbleEvent)
{
BubbleEvent = true;
if ((pVal.MenuUID == MenuRegister.MENU_ID_MODULE1) & (pVal.BeforeAction == false))
{
Module1 m = new Module1(SBOApp);
m.Display();
}
}
After the menu click, I create a module class, which then loads the Form from XML, registers its own event handlers and display the form.