这个函数可以动态建立窗体
procedure Tfmain.ShowForm(FormClass: TFormClass);
begin  With FormClass.Create(self) do
 try
     ShowModal;
    // showmessage(name);
  finally
    Free;
  end;
end;ShowForm(Tfsz);
fsz为窗体名,Tfsz是他的定义

解决方案 »

  1.   

    procedure TForm1::Button1Click(Sender: TObject);
    var
       Form2:TForm2;
    begin
       Form2:=TForm2.Create(Form1);
       Form2.ShowModal();
       delete Form2;
    end;
      

  2.   

    Application.CreateForm(TForm,Form1); //Form1为创建的窗体实例
     接下来可以设置它的属性及事件了
      

  3.   

    to 回复人: unsigned 你的delete Form2有意思~~我要试试去...
      

  4.   

    Form1:TForm;
    Form1:=TForm1.Create(Form1);
    Form1.Show
      

  5.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      i:integer;
    implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    var
    a:tform;
    begin
    a:=tform1.create(self);
    a.show;
    a.caption:=inttostr(i+1);
    inc(i);
    end;end.
      

  6.   


    to  unsigned
    procedure TForm1::Button1Click(Sender: TObject);
    var
       Form2:TForm2;
    begin
       Form2:=TForm2.Create(Form1);
       Form2.ShowModal();
       delete Form2;你的这句话看上去很有趣,可是调试不过呀
    end;
      

  7.   

    Form1:=TForm1.Create(Application)
    form1.show;
    在关闭时要记着用free销毁
      

  8.   

    procedure TForm1.Button1Click(Sender: TObject);
     var
       NewForm:Tform;
     begin
       NewForm:=Tform.Create(application);
       NewForm.Show;
     end;
      

  9.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      frm: TForm2;
     begin
       frm:=TForm2.Create(Self);
       //或者如下:
       //frm:=TForm2.Create(nil);
       frm.ShowModal;
       frm.Free;
    end;
      

  10.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      aForm:tform;
    begin
      if not assigned(aForm) then
      try
        aForm:=tform1.create(self);
        aForm.showmodel;
      finally
        FreeAndNil(aForm);
      end;     
    end;还要记住将aForm从Auto-create中去掉。