unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, FileCtrl, Buttons;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2;
// 連接第二個窗體
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if form2=nil then
form2:=Tform2.Create(application);
//動態創鍵窗體。
form2.Show;
end;
end.
***************************************************
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button2: TButton;
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
action:=cafree;
form2:=nil;
//關閉窗體
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
close;
//退出
end;
end.
多看看入門的書。很容易就會的