unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
FForm2: TForm;
{ Private-Deklarationen }
protected
procedure Notification(AComponent : TComponent; Operation : TOperation);
override;
public
constructor Create(AOwner: TComponent);
override;
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
constructor TForm1.Create(AOwner: TComponent);
begin
inherited;
FForm2 :=
nil;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// Form erzeugen, wenn nicht vorhanden
if not Assigned(FForm2)
then
begin
FForm2 := TForm2.Create(Self);
// FForm2.FreeNotification(Self);
FForm2.Show;
end;
end;
procedure TForm1.Notification(AComponent : TComponent; Operation : TOperation);
begin
inherited Notification( AComponent, Operation);
if Assigned(FForm2)
then
if (Operation = opRemove)
and (AComponent = FForm2)
then
FForm2 :=
nil;
end;
end.