Register each click on a menu

1
0
-1

Hi.

We have a migrated PB12.5.2 app, with a MDI-form and a main menu which contains 950 or so menuitems.

I would like to create a function/event which gets the name (or another unique id) each time each menuitem is clicked.

This would be used to sort the menu so that the least used menuitems are hidden over time.

Also it would be used for internal statistics.

I've looked into the pbm_* event ID's, but I cannot find one that is called each time a menuitem is clicked.

 

Thanks in advance.

 

Bjarne Anker

Maritech Systems AS

Question Tags: 

Answers

Olan Knight answered Register each click on a menu

1
0
-1

If Roland's answer works, please let us know!

I did something similar a while back. I created a function on the base menu object that LOGs the name of the menu and the menu item selected.

In every descendent menu item that you might want to log, you call this function and pass it the info you want logged. Simple.

You can log the data to a database, which is the preferred method; or you can log to a text file.

 

Good Luck,

Olan

Bjarne Anker answered Register each click on a menu

1
0
-1

Hi, and thanks for the great feedback.

I got this working now.

I declared a local external function like this:

FUNCTION ulong GetMenuString(ulong hMenu,uint uItem,REF String lpString,uint nMaxCount,uint uFlags) LIBRARY "user32.dll" ALIAS FOR "GetMenuStringA;Ansi"

(I guess you can alias "GetMenuStringW" as well, but I haven't tested this yet).

Then I added an event for my MDI-window, referring to the pbm_menuselect event ID.

And called the local external function like this:

ls_menuname = space(128)
i = 128

ll_ret = GetMenuString(hmenu,itemid,ls_menuname,i,flags)

ll_ret returns the number of characters in the menuitem, and ls_menuname contains the name itself.

I will look into the different flags and other values to try to filter out when you just hover over a menu without clicking it.

 

Thanks a lot!

Bjarne Anker answered Register each click on a menu

1
0
-1

Hi again.

 

I kinda looks like the pbm_menuselect event is not suited for my need.

Being that it fires every time I hover over a menu, even without selecting/clicking it. I just want to record each time a menu is clicked.

Do you have similar problems and perhaps a solution?

It doesn't look like "flags" can help me. And "hmenu" have different values each time my application runs.

So there really isn't much to filter the results from.

 

Regards,

Bjarne

Bjarne Anker answered Register each click on a menu

1
0
-1

Hi again.

I'm circling back to this issue, since I really want to make this work.
As previously mentioned, the pbm_menuselect event fires every time the user moves the pointer over an menuitem.
And that doesn't make any sense in my case. There is also no way to filter out if the user moves over og clicks a menuitem.

Is there any other event that I can implement to register only the click on a specific menuitem?
Or is the solution as cumbersome as to make a function on the main menu which records the clicks and call it on each menuitem's clicked() event?

Perhaps some of the Appeon engineers or SAP MVP's have another take on this issue?

 

Hopefully awaiting answers.

Bjarne Anker