16,749
社区成员
发帖
与我相关
我的任务
分享
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TmyForms = class of TForm;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
procedure ShowForm(TForms: TmyForms;var Form: TForm);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses Unit2,Unit3,Unit4;//Form2,Form3,Form4所在单元
var Form2,Form3,Form4:TForm;
procedure TForm1.ShowForm(TForms: TmyForms;var Form: TForm);
begin
if not Assigned(Form) then //未建立
Form:=TForms.Create(self)//建立
else
ShowWindow(Form.Handle,SW_SHOWNORMAL);//恢复原来尺寸
Form.Show;//显示出来
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowForm(TForm2,Form2);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ShowForm(TForm3,Form3);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ShowForm(TForm4,Form4);
end;
end.