cancel
Showing results for 
Search instead for 
Did you mean: 

C# -- Problem to Catch MenuEvent

Former Member
0 Kudos

Hi all,

The Menu Event it does not come intercepted

This is the Menu that I've insert


menuItem =  this.appl.Menus.Item("43520");
mnuPkg.Type = SAPbouiCOM.BoMenuType.mt_POPUP;
mnuPkg.String	= "Add-in";	
mnuPkg.UniqueID = "D3F_AINSCO";
mnuPkg.Enabled	= true;
mnuPkg.Position = menus.Count;
menus = menuItem.SubMenus;
menus.AddEx(mnuPkg);
			
menuItem = menus.Item("D3F_AINSCO");
mnuPkg.Type= SAPbouiCOM.BoMenuType.mt_STRING;
mnuPkg.String	= "Manage";
mnuPkg.Enabled	= true;
mnuPkg.Position = menus.Count;
mnuPkg.UniqueID = "D3F_MNT";
menus = menuItem.SubMenus;
menus.AddEx ( mnuPkg );

This is an Event Filter



evnt = evnts.Add(SAPbouiCOM.BoEventTypes.et_MENU_CLICK);
evnt.AddEx("D3F_MNT");
		

This is the Handle Event code


private void appl_MenuEvent(ref SAPbouiCOM.MenuEvent pVal, out bool BubbleEvent)
{
BubbleEvent = true;

 if ( pVal.BeforeAction == true)
 {
   switch(pVal.MenuUID)
   {
     case "D3F_MNT":
          this.LoadFormFromXml(   stPath + "\Gst.srf");
          break;
   }
 }
}

When I press on menu the form doesn't loaded.. and In the MenuEvent never it enter

where is my error??

Bye!!!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The error continue to appear... if i set an event filters ... only the ItemEvent/AppEvent Works... the MenuEvent nothing to do...

Message was edited by: H.Fay

rasmuswulff_jensen
Active Contributor
0 Kudos

In which order do you catch the events?

Know it sound silly, but I've actually seen it have inpact on what is called and what is not

try to compare your code to the following:


SboApplication.MenuEvent+=new _IApplicationEvents_MenuEventEventHandler(SetupMenuEvent);
SboApplication.ItemEvent+=new _IApplicationEvents_ItemEventEventHandler(SetupItemEvent);
SboApplication.AppEvent+=new _IApplicationEvents_AppEventEventHandler(AppEvent);	

private static void SetupMenuEvent(ref MenuEvent pVal, out bool BubbleEvent) {
  BubbleEvent = true; //[Standard]
  if(pVal.MenuUID=="1540" && pVal.BeforeAction) {
      SboApplication.MessageBox("Pressed Journal Entry",1,"OK","","");
    }
}

Regarding why the bubbleevent set set to true... This is needed for an out param in C# so this is normal

Answers (4)

Answers (4)

Former Member
0 Kudos

I Don't belevie now doesn't work...

if i open an EventMonitor this doesn't work...

Message was edited by: H.Fay

Former Member
0 Kudos

Did anyone find a solution to this issue> I have the same problem with menu events in C#?

Former Member
0 Kudos

Hi Rasmus I've Set like this:


this.SetEventFilters();

appl.ItemEvent	+=new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(appl_ItemEvent);

appl.AppEvent	+=new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(appl_AppEvent);

appl.MenuEvent	+=new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler
(appl_MenuEvent);

Thx Rasmus I've set the order like in your code and solve the problem

rasmuswulff_jensen
Active Contributor
0 Kudos

Nice... I has something to do with appEvent should alway be the last one to be handled (Strange, but I'v havn't had problem since i made that rule of mine)

former_member184566
Active Contributor
0 Kudos

Why are you bubbling the menu event? Shouldn't be there.

Then i can't see your whole menu event but it should be

Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent

Hope this helps.

Former Member
0 Kudos

Hi H.Fay,

I think the problem is that you're telling SBO to filter menu events on your own custom form, when you are actually click the main menu to open your form. The menu click event filter needs to be set up on the main menu (which is form 169). So your code needs to change to:

evnt = evnts.Add(SAPbouiCOM.BoEventTypes.et_MENU_CLICK);
evnt.AddEx("169");

Hope it helps,

Adele