建议动态创建子窗口,简单例子如下:
主窗体:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
File1: TMenuItem;
new1: TMenuItem;
window1: TMenuItem;
Cascade1: TMenuItem;
procedure Cascade1Click(Sender: TObject);
procedure new1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
Unit2;
procedure TForm1.Cascade1Click(Sender: TObject);
begin
Cascade
end;
procedure TForm1.new1Click(Sender: TObject);
var
Form2:TForm2;
begin
Form2 := TForm2.Create(Self);
Form2.Caption := TimeToStr(Now);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.WindowMenu := window1;
end;
end.
******************************************************************
子窗体:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm2 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
end.