[Lazarus] Class operators
Jose Luis
jlvolta at fibertel.com.py
Tue May 24 01:17:34 CEST 2011
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.
>
> How do you know that it is not TSpeedButton?
> Please post more code.
>
>
> > What's the correct way to cast objects in FPC ?
>
> The snippet's syntax is correct.
>
> Mattias
>
Hi, Mattias, this is the code for that action:
procedure TAyDForm.ButtnBHExecute(Sender: TObject);
var buttn:TSpeedButton;
indBtn: integer;
CanChange: boolean;
begin
if (Sender is TSpeedButton) then
begin
bttn:= TSpeedButton(Sender);
indBtn:=-1;
repeat
inc(indBtn);
until ((bttn.Name = NameButtonSheet[indBtn]) or (indBtn = 17));
if(indBtn<=17) then
begin
CanChange:=true;
with PageControl1 do
ActivePage:=Pages[indBtn];
end;
end;
end;
The code inside the 'if Sender..' statement is never execute.
J.L.
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
More information about the Lazarus
mailing list