cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with menu events

Former Member
0 Kudos

i'm creating a menu ,then , i create events like this :

Menu :

If oApplication.Menus.Exists("VidStore01") Then

Exit Sub

End If

Dim myPackage As SAPbouiCOM.MenuCreationParams

myPackage = oApplication.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)

With myPackage

.Type = SAPbouiCOM.BoMenuType.mt_POPUP

.String = "Video Store"

.Enabled = True

.UniqueID = "VidStore01"

.Position = 100

.Checked = False

End With

Dim myMenuItem As SAPbouiCOM.MenuItem

Dim myMenus As SAPbouiCOM.Menus

myMenuItem = oApplication.Menus.Item("43520")

myMenus = myMenuItem.SubMenus

myMenuItem = myMenus.AddEx(myPackage)

Try

With myMenuItem

.SubMenus.Add("Sub01", "Movies On shelf", SAPbouiCOM.BoMenuType.mt_STRING, 1)

.SubMenus.Add("Sub02", "Movies Location", SAPbouiCOM.BoMenuType.mt_STRING, 2)

.SubMenus.Add("Sub03", "Add Movie", SAPbouiCOM.BoMenuType.mt_STRING, 3)

.SubMenus.Add("Sub04", "Rent / Return Movie", SAPbouiCOM.BoMenuType.mt_STRING, 4)

End With

Catch ex As Exception

oApplication.MessageBox(ex.Message)

End Try

events :

Private Function set_filter() As SAPbouiCOM.EventFilters

Dim oFilter As SAPbouiCOM.EventFilter

set_filter = New SAPbouiCOM.EventFilters

oFilter = set_filter.Add(SAPbouiCOM.BoEventTypes.et_FORM_LOAD)

With oFilter

.AddEx("169")

End With

oFilter = set_filter.Add(SAPbouiCOM.BoEventTypes.et_FORM_CLOSE)

With oFilter

.AddEx("169")

End With

oFilter = set_filter.Add(SAPbouiCOM.BoEventTypes.et_MENU_CLICK)

With oFilter

.AddEx("169")

End With

oFilter = set_filter.Add(SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED)

With oFilter

.AddEx("169")

End With

oFilter = set_filter.Add(SAPbouiCOM.BoEventTypes.et_COMBO_SELECT)

oFilter.AddEx("169")

End Function

oApplication.SetFilter(set_filter())

It works only when i open the "EventSpy" , if i close it, no more events are catched .

someone have en idea ?

Accepted Solutions (0)

Answers (2)

Answers (2)

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Antoine,

First of all a recomendation.

When you create the SubMenus you should also use the MenuCreationParams object as for the first one you added, the method Menus.Add is deprecated from 2004 version. You should use AddEx in all cases.

Now your problem.

If you are using a filter to be able to receive menu events (click on a submenu) you should add the line:

filter = filters.Add(SAPbouiCOM.BoEventTypes.et_MENU_CLICK)

You don't need to link it to a form like for the item events. It works fine in my PC.

Plus all the other events you want to receive on specific forms like:

filter = filters.Add(SAPbouiCOM.BoEventTypes.et_CLICK)

filter.AddEx("134") ' BPs form

filter = filters.Add(SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED)

filter.AddEx("134") ' BPs form

Regards

Trinidad.

barend_morkel2
Active Contributor
0 Kudos

You have to include the menu events you are trying to catch in the filter. Run this as a test - comment the filter funtion out and you will find that the events are passed to your app.

Remember if you add a filters container (SAPbouiCOM.EventFilters) you have to specify each event you want to catch, all other events will not be passed on to your App.