我用2个窗口
 form1 form2
     当我在form1加入一个按纽在他的单击事件
中写下 
    form2:=tform2.create(self)
    form2.showmodal
  当运行时  出现 form2  它是处于击活状态
        但是我要是在 tform2.formcreate(sender:tobject)
 加入
          animatewindow(handle,400,Aw_center)
以后  form1,form2全变成灰色 alt+f4也没法结束
请大家给我解释一下我很菜  谢谢

解决方案 »

  1.   

    Form1单元文件代码: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;implementationuses Unit2;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      if not Assigned(Form2) then
      begin
        Form2:=TForm2.Create(Self);
        Form2.Show;
      end;
    end;end.
    Form2单元文件代码:unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm2 = class(TForm)
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form2: TForm2;implementation{$R *.dfm}procedure TForm2.FormCreate(Sender: TObject);
    begin
      AnimateWindow(Handle,400,AW_CENTER);
    end;end.
     工程文件代码:program Project1;uses
      Forms,
      Unit1 in 'Unit1.pas' {Form1},
      Unit2 in 'Unit2.pas' {Form2};{$R *.res}begin
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    end.-----------------------------------------------------------------------我这里不会出现死机的现象啊?
      

  2.   

    谢谢你  当你用ShowModal,的时候它就完啦
       要是没加入
    procedure TForm2.FormCreate(Sender: TObject);
    begin
      AnimateWindow(Handle,400,AW_CENTER);
    end;
    就没事         我只是想知道  为什么  没有别的意思
    要是说话方式不对 请多原谅谢谢
      

  3.   

    我想可能是你传的Handle不对,同样的代码,你用AnimateWindow(application.Handle,400,AW_CENTER); 就正常了。你看你创建窗体时用的 self, 时,用Handle就出错了,用application.Handle就对了,说明你handle是第一个窗体传入的,这是应用程序句柄又到了第一个窗体,但第二个窗体又是showmodal。所以就那样了。
    呵呵,表达能力有限,不知说清没有‘