关于网友提出的“ 多个FORM的问题如何解决”问题疑问,本网通过在网上对“ 多个FORM的问题如何解决”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: 多个FORM的问题如何解决
描述: 两个FORM 分别是FORM1和FORM2,实现FORM1启动后等待三秒自动关闭,然后跳出FORM2来。该代码如何写。本人菜。
解决方案1: 最简单的在Project单元中写 如下
program Project1;
uses
Forms,SysUtils,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Form1.Show;
Sleep(3000);
Form1.Free;
Application.CreateForm(TForm2, Form2);
Application.Run;
end.
解决方案2: begin
Start:=TStart.Create(application);
Start.Show;
Start.Update;
for i:=0 to 30 do
begin
MyTime:=GetTickCount;
while ((GetTickCount-MyTime)/1000<0.1) do
application.ProcessMessages;
if start.Tag=1 then
break;
end;
application.Initialize;
if getlasterror<>error_already_exists then
begin
Application.CreateForm(TMain, Main);
Start.Hide;
Start.Close;
application.Run;
end;
end.
就这几行代码还多啊?
解决方案3: 修正一下,启动窗体为手动创建,工程文件里面的代码:
program Project1;
uses
Forms,
Windows,
Unit1 in 'Unit1.pas' {Main},
Unit2 in 'Unit2.pas' {Start};
{$R *.res}
var
MyTime:TDateTime;
i:byte;
begin
Start:=TStart.Create(application);
Start.Show;
Start.Update;
for i:=0 to 30 do
begin
MyTime:=GetTickCount;
while ((GetTickCount-MyTime)/1000<0.1) do
application.ProcessMessages;
if start.Tag=1 then
break;
end;
application.Initialize;
if getlasterror<>error_already_exists then
begin
Application.CreateForm(TMain, Main);
Start.Hide;
Start.Close;
application.Run;
end;
end.
解决方案4: 直接sleep(3000);就可以了。
解决方案5:
program MainPRJ;
uses
Forms,
windows,
Main in 'Main.pas' {Mainform},//主窗体
Start in 'Start.pas' {StartForm};//启动窗体
{$R *.res}
var
MyTime:TDateTime;
i:byte;
begin
startform:=TStartform.Create(application);
startform.Show;
startform.Update;
for i:=0 to 30 do
begin
MyTime:=GetTickCount;
while ((GetTickCount-MyTime)/1000<0.1) do ;
application.ProcessMessages;
if startform.Tag=1 then
break;
end;
application.Initialize;
if getlasterror<>error_already_exists then
begin
Application.CreateForm(TMainorm, Mainform);
startform.Hide;
startform.Close;
application.Run;
end;
end.
解决方案6: procedure TForm1.FormShow(Sender: TObject);
begin
self.Timer1.Interval:= 3000;
self.Timer1.Enabled:= true
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
form2.Show;
self.Timer1.Enabled:= false;
end;
以上介绍了“ 多个FORM的问题如何解决”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2267054.html