Recent

Author Topic: TForm1.Button1Click run TForm1.Label1Click procedure  (Read 6643 times)

xmldom

  • New Member
  • *
  • Posts: 10
TForm1.Button1Click run TForm1.Label1Click procedure
« on: February 01, 2012, 11:05:06 pm »
Hi, I need run TForm1.Label1Click procedure after cuser click on Button1. How do I do that?
Code: [Select]
...
procedure TForm1.Button1Click(Sender: TObject);
begin
  TForm1.Label1Click();
end;   

procedure TForm1.Label1Click(Sender: TObject);
begin
  Label1.Caption:='test';
end;
...

Compile:
main.pas(118,28) Error: Wrong number of parameters specified for call to "Label1Click"
main.pas(40,15) Hint: Found declaration: TForm1.Label1Click(TObject);
main.pas(138) Fatal: There were 1 errors compiling module, stopping

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TForm1.Button1Click run TForm1.Label1Click procedure
« Reply #1 on: February 01, 2012, 11:27:58 pm »
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1Click(Sender);
end;
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

xmldom

  • New Member
  • *
  • Posts: 10
Re: TForm1.Button1Click run TForm1.Label1Click procedure
« Reply #2 on: February 01, 2012, 11:32:22 pm »
Thanks. Now it's OK :-)

How it works?

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TForm1.Button1Click run TForm1.Label1Click procedure
« Reply #3 on: February 02, 2012, 12:44:08 am »
Quote
How it works?
Simply, you need to call that method with right parameters, as compiler told you:
Code: [Select]
main.pas(118,28) Error: Wrong number of parameters specified for call to "Label1Click"
main.pas(40,15) Hint: Found declaration: TForm1.Label1Click(TObject);
In this case, Sender is Button1.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

 

TinyPortal © 2005-2018