3.如何动态的弹出和已有窗体一样(包括窗体内部空件)。

解决方案 »

  1.   

    with Tform1.create(self) do
     begin
       showmodal;
       free;
     end;
      

  2.   

    比如你现在的窗体为 frmWindowfrmWindow1:=TfrmWindow.Create(self);
      frmWindow1.Caption:='你新的窗体的名字';
      frmWindow1.ShowModal;
      

  3.   

    还要检查一下窗体就否已经创建过了,
    if not Assigned(mainfrm) then mainfrm:=Tmainfrm.Create(application);
    mainfrm.showmodal;
      

  4.   

    在uses中不要王了加已有窗体的单元文件
    如:uses unit1;
      

  5.   

    具体的想法我知道了,如下
    procedure TForm1.Button1Click(Sender: TObject);
    var form2:TForm1;
    begin
       form2:=Tform1.Create(self);
       application.CreateForm(tform1,form2);
       form2.Caption:='ok';
       form2.Top:=form1.Top+30;
       form2.ShowModal; end;
    end.但新建的窗口中的成员如adoquery1,无法控制,好像不听相应。
      

  6.   

    注:adoquery1在原窗口中已有
      

  7.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, Grids, DBGrids;type
      TForm1 = class(TForm)
        DBGrid1: TDBGrid;
        Button1: TButton;
        Button2: TButton;
        procedure Button2Click(Sender: TObject);
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button2Click(Sender: TObject);
    begin
     close;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var form2:TForm1;
    begin
       try
         form2:=TForm1.Create(Application);
         form2.Caption:='µÚ¶þ¸ö´°Ìå';
         form2.ShowModal;
       finally
         form2.free;
       end;
    end;end.
      

  8.   

    这样更好一点,先检查是否存在,不存在则创建
    if not Assigned(mainfrm) then mainfrm:=Tmainfrm.Create(application);
                      mainfrm.showmodal;