What does (Sender:TObject) mean?? As in:
procedure TForm1.Button1Click(Sender:TObject);
var
s: Integer;
begin
.....
.....
end;
What does (Sender:TObject) mean?? As in:
procedure TForm1.Button1Click(Sender:TObject);
var
s: Integer;
begin
.....
.....
end;
Sender is a reference to the component that fired the event. In this case, Sender is going to be the button the user clicked which called your Button1Click event.
This is useful when you have several components that call the same event and you need to figure out which component caused the event to be fired.
For instance, you could do something like:
if Sender = Button1 then
// ...
Hi,
Sender is a parameter which is often used when triggering events (calling Event Handlers). Most of the time I would describe it as the Object from which the Event is triggered.
But you could actually pass any object to a Sender parameter as long as it inherits from TObject in this specific case. As Jim mentioned already, in this specific cast you added an event handler to the OnClick event of Button1. So when the Button1 gets clicked, the method Tform1.ButtonClick will be executed and the sender will contain a reference to the instance o f the button you clicked.
Regards,
Stefaan