Hi Jeremy,

 

Thanks for this – it works brilliantly, and so easy to implement.  I thought it 
would be necessary to use CustomActionMenuBar, but had no idea how to do this.  
I clearly have a bit more to learn in the Delphi universe.

 

Have a great Christmas and the best new year.

 

Regards

 

Errol

 

 

From: Jeremy North [mailto:[email protected]] 
Sent: Thursday, 21 December 2017 8:25 PM
To: NZ Borland Developers Group - Delphi List <[email protected]>
Subject: Re: [DUG] How to find parameters of an Action Menu created at runtime

 

Hi Errol,

 

If the items are on the TActionMainMenuBar component then you can do the 
following:

 

type

  TCustomActionMenuBarAccess = class(TCustomActionMenuBar);

 

In the Action Execute you can then do:

 

  if TCustomActionMenuBarAccess(ActionMainMenuBar1).FSelectedItem <> nil then

    ShowMessage('Selected Item: ' + 
TCustomActionMenuBarAccess(ActionMainMenuBar1).FSelectedItem.Caption);

 

where ActionMainMenuBar1 is the name of the TActionMainMenuBar component on the 
form.

 

If the items are created on a toolbar, then you can use the 
TAction(Sender).ActionComponent property as the TAction is the sender in these 
cases.

 

cheers,

Jeremy

 

 

 

On Thu, Dec 21, 2017 at 7:47 AM, Errol Anderson <[email protected] 
<mailto:[email protected]> > wrote:

My program creates Action Menu items at runtime, with the caption of each item 
set to a value returned by a database query. The OnExecute procedure is the 
same for all items. 

When I click on an item, I need to obtain the item caption for the OnExecute 
procedure, to use in another query. I have tried the following (analogous to 
TMenuItem for a popup menu):

sCaption := TActionClientItem(Sender).Caption;

However, this always returns an empty string. I have searched the web and the 
Delphi Help to no avail. I am aware that Caption is a published property, but 
the public property Index also fails.

I presume I am doing something wrong here, but cannot figure out what. Any help 
appreciated. 

Regards

 

Errol Anderson 


_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected] <mailto:[email protected]> 
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] 
<mailto:[email protected]>  with Subject: unsubscribe

 

_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] with 
Subject: unsubscribe

Reply via email to