Using the Sender Parameter
In an event handler, the Sender parameter indicates which component received the event and therefore called the handler. Sometimes it is useful to have several components share an event handler that behaves differently depending on which component calls it. You can do this by using the Sender parameter.
For example, the following code displays the title of the application in the caption of a dialog box only if the OnClick event was received by Button1.
procedure TMainForm.Button1Click(Sender: TObject); begin if Sender = Button1 then AboutBox.Caption := 'About ' + Application.Title else AboutBox.Caption := ''; AboutBox.ShowModal; end;