unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,System.Contnrs, Unit2;
type
TMainForm = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
List: TComponentList;
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
procedure TMainForm.Button1Click(Sender: TObject);
Var
T : Tform;
begin
List.OwnsObjects:=True;
T:=TForm2.Create(Nil);
List.Add(T);
T.Show;
end;
procedure TMainForm.Button2Click(Sender: TObject);
var
Antal : Integer;
begin
Antal:=List.Count;
Memo1.Lines.Add('Forms Count '+IntToStr(Antal));
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
ReportMemoryLeaksOnShutdown:=True;
List:= TComponentList.Create;
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
List.Free;
end;
end.
object MainForm: TMainForm
Left = 0
Top = 0
Caption = 'MainForm'
ClientHeight = 303
ClientWidth = 641
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 32
Top = 16
Width = 105
Height = 25
Caption = 'New Window'
TabOrder = 0
OnClick = Button1Click
end
object Memo1: TMemo
Left = 192
Top = 16
Width = 433
Height = 273
Lines.Strings = (
'Memo1')
TabOrder = 1
end
object Button2: TButton
Left = 32
Top = 55
Width = 105
Height = 25
Caption = 'Info'
TabOrder = 2
OnClick = Button2Click
end
end
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TSubForm = class(TForm)
Label1: TLabel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
SubForm: TSubForm;
implementation
{$R *.dfm}
procedure TSubForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Hide;
Action := caFree;
end;
end.
object SubForm: TSubForm
Left = 0
Top = 0
Caption = 'SubForm'
ClientHeight = 299
ClientWidth = 635
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnClose = FormClose
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 120
Top = 48
Width = 60
Height = 13
Caption = 'Second form'
end
end
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.