D
Delphi之旅
Unregistered / Unconfirmed
GUEST, unregistred user!
待进入窗体:form1如下设置:
var
logined:boolean;
begin
procedure TForm1.FormCreate(Sender: TObject);
begin
Logined:=False;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
if not Logined then form2.Showmodal;
end;
密码登陆界面form2如下设置:
private
Passtime:byte;
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
Passtime:byte;
implementation
uses unit3,unit1;
{$R *.dfm}
procedure TForm2.BitBtn2Click(Sender: TObject);
begin
Close;
Application.Terminate;
end;
procedure TForm2.BitBtn1Click(Sender: TObject);
begin
inc(PassTime);
if Edit1.Text=MyPass then
begin
form1.Logined:=True;
form1.WindowState:=wsMaximized;
Close;
end else
begin
Label1.Caption:=Format('密码错误第%d次,请重新输入:',[PassTime]);
if PassTime>=3 then
begin
BitBtn2.Click;
end else
begin
Edit1.Text:='';
Edit1.SetFocus;
end;
end;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
passtime:=0;
end;
end.
数据模块form3.已建好,提供mypass变量。
可是每次进入登陆后输入密码即使有误,也可进入form1.
如果把form1中的form2.showmadal改为form2.show.这时错误密码有 提示信息,
并且实现了此功能,但form2的取消按钮出错。
这是为什么?
var
logined:boolean;
begin
procedure TForm1.FormCreate(Sender: TObject);
begin
Logined:=False;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
if not Logined then form2.Showmodal;
end;
密码登陆界面form2如下设置:
private
Passtime:byte;
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
Passtime:byte;
implementation
uses unit3,unit1;
{$R *.dfm}
procedure TForm2.BitBtn2Click(Sender: TObject);
begin
Close;
Application.Terminate;
end;
procedure TForm2.BitBtn1Click(Sender: TObject);
begin
inc(PassTime);
if Edit1.Text=MyPass then
begin
form1.Logined:=True;
form1.WindowState:=wsMaximized;
Close;
end else
begin
Label1.Caption:=Format('密码错误第%d次,请重新输入:',[PassTime]);
if PassTime>=3 then
begin
BitBtn2.Click;
end else
begin
Edit1.Text:='';
Edit1.SetFocus;
end;
end;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
passtime:=0;
end;
end.
数据模块form3.已建好,提供mypass变量。
可是每次进入登陆后输入密码即使有误,也可进入form1.
如果把form1中的form2.showmadal改为form2.show.这时错误密码有 提示信息,
并且实现了此功能,但form2的取消按钮出错。
这是为什么?