There is this link How do I Invoke a procedure when inside another procedure in Pascal But its not exactly my case.
procedure TForm1.Button1Click(Sender: TObject);
var
[...]
begin
// click on button
[...]
end;
and I have this procedure
procedure TForm1.CheckListBox2DblClick(Sender: TObject);
begin
// on double click in flags
[the same code like above]
end;
i tryed this but it does not work
procedure TForm1.CheckListBox2DblClick(Sender: TObject);
begin
TForm1.Button1Click;
end;
then I tryed this
procedure TForm1.CheckListBox2DblClick(Sender: TObject);
begin
TForm1.Button1Click(Sender: TObject);
end;
it also does not work
Can somebody please help me ?
Just call it directly, using either nil
or another component as the Sender
:
procedure TForm1.CheckListBox2DblClick(Sender: TObject);
begin
Button1Click(nil);
end;
procedure TForm1.CheckListBox2DblClick(Sender: TObject);
begin
Button1Click(CheckListBox2);
end;
Note you don't use the classname (or variable name) of the form itself, since you're calling from the current instance of the form. IOW, do not use TForm1
or Form1
inside of a class method; that limits you to a specific instance of the form instead of being available to all instances. If you need to qualify it, use Self
, as in Self.Button1Click(nil);
.