1. Bjarne Anker
  2. PowerBuilder
  3. Monday, 9 October 2017 13:51 PM UTC

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

Roland Smith Accepted Answer Pending Moderation
  1. Monday, 9 October 2017 15:01 PM UTC
  2. PowerBuilder
  3. # 1

This might work. Add the pbm_menuselect event to the window.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646352(v=vs.85).aspx

​Whether you'll be able to determine the menuitem I'm not sure.

 

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 9 October 2017 17:31 PM UTC
  2. PowerBuilder
  3. # 2

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

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 9 October 2017 19:04 PM UTC
  2. PowerBuilder
  3. # 3

Here is another link to someone who got pbm_menuselect to work for them.

https://groups.google.com/forum/?hl=en#!msg/powersoft.public.powerbuilder.powerscript/vKkam2e0dYo/T06O38J4HTQJ

​You can use the GetMenuString API function to get the menu name from the arguments pass to pbm_menuselect.

Comment
There are no comments made yet.
Bjarne Anker Accepted Answer Pending Moderation
  1. Wednesday, 11 October 2017 08:36 AM UTC
  2. PowerBuilder
  3. # 4

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!

Comment
There are no comments made yet.
Bjarne Anker Accepted Answer Pending Moderation
  1. Thursday, 12 October 2017 11:32 AM UTC
  2. PowerBuilder
  3. # 5

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

Comment
There are no comments made yet.
Bjarne Anker Accepted Answer Pending Moderation
  1. Thursday, 16 November 2017 09:49 AM UTC
  2. PowerBuilder
  3. # 6

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

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.