Hi Errol

I have struck a similar situation with runtime objects.

Suggestion ....
Instead of  ...
xObjectName.Property
Try ...
(xObject as TObjectType). Property

You would expect either to work but I have found situations where only
option two works.

Regards

Graham Marsden
ElectroPlan Ltd


On Dec 21, 2017 5:10 PM, <[email protected]> wrote:

Send Delphi mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://listserver.123.net.nz/mailman/listinfo/delphi
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Delphi digest..."

Today's Topics:

   1. Re: How to find parameters of an Action Menu created at
      runtime (Errol Anderson)
   2. Re: How to find parameters of an Action Menu created      at
      runtime (David O'Brien)


---------- Forwarded message ----------
From: Errol Anderson <[email protected]>
To: "'NZ Borland Developers Group - Delphi List'" <
[email protected]>
Cc:
Bcc:
Date: Thu, 21 Dec 2017 14:01:05 +1300
Subject: Re: [DUG] How to find parameters of an Action Menu created at
runtime

Hi David



Thanks for your suggestion.  Unfortunately it raises the following error:



Because there may be multiple items with the same action but different
captions, I figured I had to pick the item caption, not the action
caption.



I have tried creating one or multiple items at designtime as a test, but I
get the same results every time – namely TActionClientItem(Sender).Caption
returns a null string, and TAction(TActionClientItem(Sender).Action).Caption
fails.  It appears that TActionClientItem does not act like TMenuItem which
is very disappointing.



Best regards



Errol



*From:* David O'Brien [mailto:[email protected]]
*Sent:* Thursday, 21 December 2017 9:58 AM
*To:* NZ Borland Developers Group - Delphi List <
[email protected]>
*Subject:* Re: [DUG] How to find parameters of an Action Menu created at
runtime



The Sender will be the menu item. Try   TAction(TActionClientItem
(Sender).Action).Caption.



*From:* [email protected] [mailto:delphi-bounces@
listserver.123.net.nz <[email protected]>] *On Behalf Of
*Errol Anderson
*Sent:* Thursday, 21 December 2017 9:47 am
*To:* [email protected]
*Subject:* [DUG] How to find parameters of an Action Menu created at runtime



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


---------- Forwarded message ----------
From: "David O'Brien" <[email protected]>
To: NZ Borland Developers Group - Delphi List <[email protected]>
Cc:
Bcc:
Date: Thu, 21 Dec 2017 04:09:33 +0000
Subject: Re: [DUG] How to find parameters of an Action Menu created at
runtime

No worries. I didn’t actually try it, just a thought…



“If an action band contains a TCustomizeBandAction standard action, the
user of the application can change this property. Because the caption can
be changed at runtime, the default caption that will be used, should be set
in the action itself and not in the TActionClientItem
<http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/ActnMan_TActionClientItem.html>
object.”



*From:* [email protected] [mailto:delphi-bounces@
listserver.123.net.nz] *On Behalf Of *Errol Anderson
*Sent:* Thursday, 21 December 2017 2:01 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 David



Thanks for your suggestion.  Unfortunately it raises the following error:



Because there may be multiple items with the same action but different
captions, I figured I had to pick the item caption, not the action
caption.



I have tried creating one or multiple items at designtime as a test, but I
get the same results every time – namely TActionClientItem(Sender).Caption
returns a null string, and TAction(TActionClientItem(Sender).Action).Caption
fails.  It appears that TActionClientItem does not act like TMenuItem which
is very disappointing.



Best regards



Errol



*From:* David O'Brien [mailto:[email protected] <[email protected]>]
*Sent:* Thursday, 21 December 2017 9:58 AM
*To:* NZ Borland Developers Group - Delphi List <
[email protected]>
*Subject:* Re: [DUG] How to find parameters of an Action Menu created at
runtime



The Sender will be the menu item. Try   TAction(TActionClientItem
(Sender).Action).Caption.



*From:* [email protected] [mailto:delphi-bounces@
listserver.123.net.nz <[email protected]>] *On Behalf Of
*Errol Anderson
*Sent:* Thursday, 21 December 2017 9:47 am
*To:* [email protected]
*Subject:* [DUG] How to find parameters of an Action Menu created at runtime



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

_______________________________________________
Delphi mailing list
[email protected]
http://listserver.123.net.nz/mailman/listinfo/delphi
_______________________________________________
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