[Lazarus] Class operators
Mattias Gaertner
nc-gaertnma at netcologne.de
Tue May 24 09:45:25 CEST 2011
On Mon, 23 May 2011 20:02:42 -0400
Jose Luis <jlvolta at fibertel.com.py> wrote:
> On Tue, 2011-05-24 at 00:35 +0100, Martin wrote:
> > On 24/05/2011 00:17, Jose Luis wrote:
> > > On Tue, 2011-05-24 at 00:30 +0200, Mattias Gaertner wrote:
> > >> On Mon, 23 May 2011 18:06:31 -0400
> > >> Jose Luis<jlvolta at fibertel.com.py> wrote:
> > >>
> > >>> Hi all:
> > >>>
> > >>> I've tried to cast the argument 'Sender' from a call to an event
> > >>> procedure, but it didn't work. The event is triggered by a TSpeedButton
> > >>> push, and the code of the action call contain the sentence:
> > >>>
> > >>> -- if Sender is TSpeedButton then
> > >>> -- buttn:=TSpeedButton(Sender);
> > >>>
> > >>> The code compile without raising error or warning, but at run-time
> > >>> Sender is not of TSpeedButton's type, like it is in Delphi.
> > >>
> > ....
> > > procedure TAyDForm.ButtnBHExecute(Sender: TObject);
> > > var buttn:TSpeedButton;
> > > indBtn: integer;
> > > CanChange: boolean;
> > > begin
> > > if (Sender is TSpeedButton) then
> >
> > Set a breakpoint, and when the execution stops at it evaluate (ctrl-f7
> > or watch window) the following
> > (^^PChar(Sender)^+3)^+1
> >
> > It should give you the real classname
> >
> >
> Hi Martin, thank you for your email;
>
> The watch window says the value of Sender is:
> 0x8327251 'TAction' #148
>
> What does this mean ?, it was a SpeedButton that triggered the action,
> but I received a TAction object.
I guess you can use
if (Sender is TAction) and (TAction(Sender).ActionComponent is
TSpeedbutton) then
begin
Btn:=TSpeedButton(TAction(Sender).ActionComponent);
Mattias
More information about the Lazarus
mailing list