请问各位:我在程序中新建了一个MDI父窗体form2,一个MDI子窗体form3,一个普通窗体form1,我把form1设置成启动窗体,在它上面的一个按钮中写入启动form2的代码:比如
procedure TForm1.Button1Click(Sender: TObject);
var form2:TForm2;
begin
form2:=TForm2.Create(Application);
form2.Show;
end;end.
启动form2后,在form2中用类似代码启动其子窗体form3,但总是抛出例外,
如果将form2改成初始启动窗口再用代码启动子窗体form3就不会有例外,请问是什么原因?如何解决??
procedure TForm1.Button1Click(Sender: TObject);
var form2:TForm2;
begin
form2:=TForm2.Create(Application);
form2.Show;
end;end.
启动form2后,在form2中用类似代码启动其子窗体form3,但总是抛出例外,
如果将form2改成初始启动窗口再用代码启动子窗体form3就不会有例外,请问是什么原因?如何解决??
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
Tsplashform = class(TForm)
Timer1: TTimer;
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Panel5: TPanel;
Panel6: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Timer2: TTimer;
Panel7: TPanel;
Panel8: TPanel;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
splashform: Tsplashform;
var i:integer;
implementation{$R *.dfm}procedure Tsplashform.FormCreate(Sender: TObject);
begin
i:=0;
AnimateWindow(handle,100,AW_CENTER);
//产生从中央到四周的效果
panel7.Width:=0;
panel8.Width:=0;
panel8.Left:=panel1.Left+panel1.Width;
end;procedure Tsplashform.Timer1Timer(Sender: TObject);
begin
timer1.Enabled:=false;
//实质上是控制封面的显示
end;
//产生动态比率的显示
procedure Tsplashform.Timer2Timer(Sender: TObject);
begin
i:=i+1;
label1.Caption:=inttostr(i);
panel7.width:=panel7.width+4;
panel8.Left:=panel8.Left-4;
panel8.width:=panel8.Width+4;
end;
end.
//另外
program Serverdpr;uses
Forms,
Server in 'Server.pas' {Form1},
SServer in 'SServer.pas' {Serverform},
Unit4 in 'Unit4.pas' {Form4},
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas' {splashform},
Unit1 in 'Unit1.pas' {zypNeoForm};{$R *.RES}begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TServerform, Serverform);
Application.CreateForm(TForm4, Form4);
Application.CreateForm(TForm2, Form2);
Application.CreateForm(TzypNeoForm, zypNeoForm);
splashform:=tsplashform.create(application);
splashform.show;
splashform.update;
while splashform.timer1.enabled do
//封面退出的条件
application.processmessages;
splashform.hide;
splashform.Free;
Application.Run;
end.
//该问题真的挺简单的!