I have a procedure FormShow () which is executed when a new window is shown, which randomly reads information from a file. And there is a button, when clicked, I would like to call the same procedure, more precisely, the procedure code. How to do it?
Or you can
procedure TForm1.FormShow(Sender: TObject) begin .... end; procedure TForm1.Button1Click(Sender: TObject) begin FormShow(Form1) end;
General code - in a separate procedure, and call it from where you want)
procedure TForm1.Nya() begin // Do nya end; procedure TForm1.FormShow(Sender: TObject) begin Nya(); end; procedure TForm1.Button1Click(Sender: TObject) begin Nya(); end;
As far as I remember, you can even select the TForm1.FormShow method in the Object Inspector for OnClick buttons and you won't even need to write any code.