Recent

Author Topic: How to use the 'Sender' in onclick event of KOLButton1  (Read 9322 times)

nshark

  • Newbie
  • Posts: 1
How to use the 'Sender' in onclick event of KOLButton1
« 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'?
« Last Edit: January 15, 2010, 12:49:37 am by nshark »

Paul Ishenin

  • Sr. Member
  • ****
  • Posts: 274
Re: How to use the 'Sender' in onclick event of KOLButton1
« Reply #1 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

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2496
Re: How to use the 'Sender' in onclick event of KOLButton1
« Reply #2 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 ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

JohnvdWaeter

  • Full Member
  • ***
  • Posts: 168
    • http://www.jvdw.nl
Re: How to use the 'Sender' in onclick event of KOLButton1
« Reply #3 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