商务合作:179001057@qq.com

不一样的登录窗口验证方式

技术2022-05-11  1


某平台价值19860元的编程课程资料免费领取【点我领取】


登录窗口代码

 

......

 

  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.

 


最新回复(0)