关于程序的启动窗口问题(0分)

  • 主题发起人 主题发起人 bluesky1000
  • 开始时间 开始时间
B

bluesky1000

Unregistered / Unconfirmed
GUEST, unregistred user!
各位大大,我是个菜鸟,有一问题请教。
我做了一个程序。程序中有5个FORM和1个ABOUTBOX,程序做完后,想将FORM6做成启动窗口,
效果应该是FORM6出现7秒后,关闭,然后FORM1(主程序)启动。可我做了半天没个结果,代码
如下:

program Project1;

uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas' {Form3},
Unit4 in 'Unit4.pas' {Form4},
Unit5 in 'Unit5.pas' {AboutBox},
Unit6 in 'Unit6.pas' {Form6};

{$R *.res}

begin

Application.Initialize;
Application.CreateForm(TForm6, Form6);
form6.Show;
form6.Update;
form6.Close;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.CreateForm(TForm3, Form3);
Application.CreateForm(TForm4, Form4);
Application.CreateForm(TAboutBox, AboutBox);
Application.Run;
end.

{然后在FORM6的onclose事件中加入以下代码:}

procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin

sleep(7000);
end;



可运行的结果是:FORM6如愿的出来了,但后面的FORM1(主程序)却出不来了,请问我的代码有错吗?

大大有何解决办法?

 
试试这样:
begin

Application.Initialize;
Form6:=Tform6.create(Application);
form6.Show;
form6.Update;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.CreateForm(TForm3, Form3);
Application.CreateForm(TForm4, Form4);
Application.CreateForm(TAboutBox, AboutBox);
form6.Hide;
form6.free;
Application.Run;
end.


请确保FORM6不是自动创建窗体
 
在上面這位兄弟的基礎上再加一點。
Form1一定要是主窗體。
begin

Application.Initialize;
Form6:=Tform6.create(Application);
form6.Show;
form6.Update;
// Sleep(6) 可加在這里
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.CreateForm(TForm3, Form3);
Application.CreateForm(TForm4, Form4);
Application.CreateForm(TAboutBox, AboutBox);
form6.Hide;
form6.free;
Application.Run;
end.

 
加入SLEEP后提示:
[Error] Project1.dpr(19): Undeclared identifier: 'sleep'
是什么意思啊?
 
谢谢大家,谢谢siyan,coolzew:我用你们的方法试成了。
begin

Application.Initialize;
Form6 := TForm6.Create(Application);
Form6.Show;
Form6.Update;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.CreateForm(TForm3, Form3);
Application.CreateForm(TForm4, Form4);
Application.CreateForm(TAboutBox, AboutBox);
form6.Hide;
Form6.Free;
Application.Run;
end.


然后
加了form6.hide;在FORM6的ONHIDE事件中加入了:
procedure TForm6.FormHide(Sender: TObject);
begin

sleep(7000);
end;



真诚的谢谢你们!上帝会保佑你们的!:)
 
分呢?咦!怎么是0分题!
 
对不起啦,我现在只有40分了,有分一定给你,我可记住你了~~~[:D]
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部