登录窗口代码
......
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
function CheckUserAndPassword: boolean;
public
{ Public declarations }
class function Execute : Boolean;
end;
......
procedure TfLogin.btn1Click(Sender: TObject);
begin
if not CheckUserAndPassword then
MsgBox('密码错误! ',1 ); {自己简化过的messagebox函数}
end;
function TfLogin.CheckUserAndPassword: boolean;
begin
if (edt1.text ='joe ' ) and (edt2.text='123' ) then
ModalResult := mrOk;
Result := ModalResult = mrOk;
end;
class function TfLogin.Execute: Boolean;
begin
with TfLogin.Create(nil ) do begin
try
Result := ShowModal = mrOk;
finally
Free;
end;
end;
end;
......
工程文件进行修改
......
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
if not TfLogin.Execute then begin
fdm.Free;
halt;
end;
Application.CreateForm(TfMain, fMain);
Application.Run;
end.