Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TActionList action enabled ?

10 views
Skip to first unread message

Bugs

unread,
May 18, 2001, 5:47:01 PM5/18/01
to
I want to loop through a TActionList and for each action in a specific
category, set that Action's Enabled property. I have the looping part done
and have identified the Action's category, but starting at ActionList how
would I drill down the heirarchy to set the Enabled property?
Any hints?
Thanks!
Bugs

Robert den Hartog

unread,
May 18, 2001, 7:43:59 PM5/18/01
to
I hope this is what you're asking:
You can just set the (ActionList1.Actions[index] as TAction).Enabled
property. Remind that TActionList contains a property Actions[Index]:
TContainedAction, you'll have to typecast this Action to a TAction or a
TCustomAction. You'll probably 1st want to check if Actions[index] is of
type TAction/TCustomAction before you do the operation:

If (ActionList1.Actions[index] is TAction) then
(ActionList1.Actions[index] as TAction).Enabled := True;

Gr.

Robert

Bugs <do...@spamonme.com> wrote in message news:3b0597f2$1_2@dnews...

Bugs

unread,
May 18, 2001, 11:52:46 PM5/18/01
to
"Robert den Hartog" <robert.d...@prive.ordina.nl> wrote

> I hope this is what you're asking:
> You can just set the (ActionList1.Actions[index] as TAction).Enabled
> property. Remind that TActionList contains a property Actions[Index]:
> TContainedAction, you'll have to typecast this Action to a TAction or a
> TCustomAction. You'll probably 1st want to check if Actions[index] is of
> type TAction/TCustomAction before you do the operation:
>
> If (ActionList1.Actions[index] is TAction) then
> (ActionList1.Actions[index] as TAction).Enabled := True;
>
Yep, that works perfectly! Sorry, I didn't really phrase that question
well.
Thanks Robert!
Bugs

Peter Below (TeamB)

unread,
May 19, 2001, 9:55:59 AM5/19/01
to
In article <3b05b3cb_2@dnews>, Robert den Hartog wrote:
> If (ActionList1.Actions[index] is TAction) then
> (ActionList1.Actions[index] as TAction).Enabled := True;
>

Just for the sake of promoting an efficient coding style <g>: if you do
the Is test first you don't need to use an As typecast (since you have
already tested that the object is the correct type). So you can change
this to

If (ActionList1.Actions[index] is TAction) then

TAction(ActionList1.Actions[index]).Enabled := True;

which is a tad faster and generates less code.


Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Robert den Hartog

unread,
May 19, 2001, 10:27:17 AM5/19/01
to
Thanx Peter,

I didn't know that.


Peter Below (TeamB) <10011...@compuXXserve.com> wrote in message
news:VA.0000708...@antispam.compuserve.com...

0 new messages