有两个窗体(form1,form2),当我从form1中按一按钮进入form2的时候,我想把form1给关闭掉,怎么做????

解决方案 »

  1.   

    如过form1是主窗口,关掉整个应用程序就结束了。应该把form1隐藏起来。
    form2.show;
    form1.hide;
      

  2.   

    form2.hide;
    就这个。。可以把第二个窗口隐藏。。就这么做。
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, 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;implementation
        uses unit2;
    {$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      form2.show;
      form1.Hide;
    end;end.*******************
    unit Unit2;interfaceuses
      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
    uses unit1;
    {$R *.dfm}procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      form1.close;
    end;end.
      

  4.   

    form2.show;
    form1.hide;//form1.close;//form1.terminate;
      

  5.   

    没有必要关掉
    我以前也有这样的想法
    想隐藏也可以
    form1.visible:=false;