X
xucongbo
Unregistered / Unconfirmed
GUEST, unregistred user!
我编的程序为:先出现一个闪现窗体,然后出现登陆窗体 闪现窗体关闭,(在登陆窗体中输入用户名、密码,点确定就可进入主体,点取消关闭此程序),一开始我用着没问题,但我在主窗体加上数据库后,就出现,点确定可顺利进入主窗体,一切正常,但点取消时就会出错,请各位帮我看看此代码哪儿写的不对,谢谢,
Project1中的代码为:
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas' {Form3},
Unit4 in 'Unit4.pas' {Form4};
{$R *.res}
begin
Application.Initialize;
Form2:=TForm2.Create(Application);
Form2.Show;
Form2.Update;
try
Try
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm4, Form4);
Except
end;
Finally
Form2.Free;
end;
Application.CreateForm(TForm3, Form3);
if form3.ShowModal = 1 then
begin
form3.hide;
form3.Free;
Application.Run;
end;
end.
form3中的代码为:(form3为登陆窗体,Button1为确定,Button2为取消)
procedure TForm3.Button1Click(Sender: TObject);
begin
modalresult:=1;
if form1<>nil then
form1.Show;
end;
procedure TForm3.Button2Click(Sender: TObject);
begin
close;
end;
form2为闪现窗体。
请大家看为什么点取消时就出错怎么解决(其它一切正常)
Project1中的代码为:
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas' {Form3},
Unit4 in 'Unit4.pas' {Form4};
{$R *.res}
begin
Application.Initialize;
Form2:=TForm2.Create(Application);
Form2.Show;
Form2.Update;
try
Try
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm4, Form4);
Except
end;
Finally
Form2.Free;
end;
Application.CreateForm(TForm3, Form3);
if form3.ShowModal = 1 then
begin
form3.hide;
form3.Free;
Application.Run;
end;
end.
form3中的代码为:(form3为登陆窗体,Button1为确定,Button2为取消)
procedure TForm3.Button1Click(Sender: TObject);
begin
modalresult:=1;
if form1<>nil then
form1.Show;
end;
procedure TForm3.Button2Click(Sender: TObject);
begin
close;
end;
form2为闪现窗体。
请大家看为什么点取消时就出错怎么解决(其它一切正常)