[DUG] How to find parameters of an Action Menu created at runtime

Jeremy North jeremy.north at gmail.com
Thu Dec 21 20:24:58 NZDT 2017


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 <errol.anderson at gsds.co.nz>
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: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
> Subject: unsubscribe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20171221/1f19801c/attachment.html 


More information about the Delphi mailing list