unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TGrundProgramm =
class(TControl)
frmFenster: TForm;
protected
Procedure CloseFormInfo(Sender:TObject;
var Action: TCloseAction);
public
Procedure Showwindow;
Constructor Create(AOwner:TComponent);
override;
Destructor Destroy;
Override;
end;
TForm5 =
class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
g:TGrundProgramm;
{ Public-Deklarationen }
end;
var
Form5: TForm5;
implementation
uses Unit6;
{$R *.dfm}
{ TGrundProgramm }
procedure TGrundProgramm.CloseFormInfo(Sender: TObject;
var Action: TCloseAction);
begin
Free;
end;
constructor TGrundProgramm.Create(AOwner: TComponent);
begin
inherited;
frmFenster := TClassForm.Create(Self);
frmFenster.OnClose := CloseFormInfo;
end;
destructor TGrundProgramm.Destroy;
begin
Showmessage('
Destroy');
inherited;
end;
procedure TGrundProgramm.Showwindow;
begin
frmFenster.Show;
end;
procedure TForm5.Button1Click(Sender: TObject);
begin
g := TGrundProgramm.Create(self);
g.Showwindow;
end;
procedure TForm5.Button2Click(Sender: TObject);
begin
// Destroy wird beim drücken diese Buttons ausgeführt, ebenso beim Schliessen des frmFenster
if Assigned(g)
then FreeAndNil(g);
end