unit1.pas

来自「Delphi basic program. Basic programing」· PAS 代码 · 共 93 行

PAS
93
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
    times : integer;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit3, Unit4;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
  var
    passfile : textfile;
    passstr : string;
begin
  assignfile(passfile,'c:\passward\master.txt');
  reset(passfile);
  readln(passfile,passstr);
  closefile(passfile);
  times:=times+1;
  if edit1.Text=passstr then
     masterform.show
  else
    begin
      if MessageDlg('密码输入错误,是否退出?',mtConfirmation,[mbYes,mbNo],0)
         =mryes then close
      else if times<5 then
         edit1.SetFocus
      else
       begin
        MessageDlg('对不起,密码输入错误达到5次!请退出。',mtInformation,[mbOk],0);
        application.Terminate;
       end;
    end;
end;

procedure TForm1.Button2Click(Sender: TObject);
  var
    passfile : textfile;
    passstr : string;
begin
  assignfile(passfile,'c:\passward\reader.txt');
  reset(passfile);
  readln(passfile,passstr);
  closefile(passfile);
  times:=times+1;
  if edit1.Text=passstr then
    readerform.show
  else
    begin
      if MessageDlg('密码输入错误,是否退出?',mtConfirmation,[mbYes,mbNo],0)
         =mryes then close
      else if times<5 then edit1.SetFocus
      else
       begin
        MessageDlg('对不起,密码输入错误达到5次!请退出。',mtInformation,[mbOk],0);
        application.Terminate;
       end;
    end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  close;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?