There are always several ways to kill a cat. The following way works well for me, but does not free the second form (only to recreate it when needed later).
In your project have a Close TBitBtn with its Kind set to bkClose. This will simply close the form (set its ModalResult to mrClose) after use, but not free it. Your basic project skeleton would then be a main form:
unit mainForm;
{$mode objfpc}{$H+}
interface
uses
Forms, StdCtrls, secondForm, Classes;
type
{ TForm1 }
TForm1 = class(TForm)
BShowForm2: TButton;
procedure BShowForm2Click(Sender: TObject);
end;
var
Form1: TForm1;
Form2: TForm2=nil;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.BShowForm2Click(Sender: TObject);
begin
if Form2=nil then
Form2:=TForm2.Create(Application);
form2.Show;
end;
end.
and your second form skeleton would be:
unit secondForm;
{$mode objfpc}{$H+}
interface
uses
Forms, Buttons;
type
{ TForm2 }
TForm2 = class(TForm)
BClose: TBitBtn;
end;
implementation
{$R *.lfm}
end.
Make sure you set the second form not to be autocreated (via Project Options or by editing your project's .lpr).