Lazarus

Programming => Packages and Libraries => KOL => Topic started by: nshark on January 15, 2010, 12:46:37 am

Title: How to use the 'Sender' in onclick event of KOLButton1
Post by: nshark on January 15, 2010, 12:46:37 am
I'm Creating a program.it will work on WinCE.
A lot of buttons share an event in a form.

The following is my code

procedure TForm3.Button3Click(Sender: PObj);
begin
  EditBox2.Text:=(Sender as TKOLButton).Caption;
end;      

I get an error 'unit3.pas(124,26) Error: Class or interface type expected, but got "PControl"' when I run Quick compile.

How can I use the 'Sender'?
Title: Re: How to use the 'Sender' in onclick event of KOLButton1
Post by: Paul Ishenin on January 15, 2010, 12:59:08 am
I don't know what is PObj but maybe so:

if Assigned(Sender) then
  EditBox2.Text := PKOLButton(Sender)^.Caption
Title: Re: How to use the 'Sender' in onclick event of KOLButton1
Post by: Marc on January 15, 2010, 12:24:37 pm
I don't know what is PObj but maybe so:

if Assigned(Sender) then
  EditBox2.Text := PKOLButton(Sender)^.Caption

If this is a method handler for a TButton.OnClick, then Sender must be a TObject. Don't invent other types there.
Dunno it htis is the case for a TKOLButton too ?
Title: Re: How to use the 'Sender' in onclick event of KOLButton1
Post by: JohnvdWaeter on January 27, 2010, 11:57:33 am
I don't have it at hand now, so I don't know the name, but in KOL.pas there are some settings you can switch On or Off.

One of them has to do with the Sender-param. By default it is Off, so switch it on...

Usually Youri (who maintains KOL-CE) jumps in here, but have not seen him for a while...

kind regards,
John
TinyPortal © 2005-2018