⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setpasswordu.pas

📁 Delphi 7基础编程的源代码
💻 PAS
字号:
unit SetPasswordU;

interface

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

type
  TSetPasswordForm = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    OKBtn: TButton;
    CancelBtn: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
  private
        Verified:Boolean;
    { Private declarations }
  public
        PassWord:PChar;
    { Public declarations }
  end;

var
  SetPasswordForm: TSetPasswordForm;
  function SetPassWord(PWord:PChar):Boolean;export;

implementation

{$R *.dfm}
function SetPassWord(PWord:PChar):Boolean;
    var
    SetPasswordForm: TSetPasswordForm;
begin
    Result := False;
    SetPasswordForm := TSetPasswordForm.Create(Application);
    try
      with SetPasswordForm do
        if ShowModal =mrOK then
        begin
          Strcopy(PWord,StrUpper(Password));
          Result := True;
        end;
    finally
        SetPasswordForm.Free;
    end;
end;





procedure TSetPasswordForm.FormCreate(Sender: TObject);
begin
  Verified := False;
  PassWord := StrAlloc(40);
  OKBtn.Enabled := False;
  Label1.Caption := '请输入密码:        ';
end;

procedure TSetPasswordForm.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if Edit1.Text = '' then Exit;
  if Key = #13 then
  begin
      if Verified then
        If StrPas(PassWord) = Edit1.Text then
        begin
          OKBtn.Enabled := True;
          Edit1.Enabled := False;
          OKBtn.SetFocus;
        end
        else
        begin
          Verified := False;
          MessageDlg('密码不正确!         ',mtWarning,[mbOK],0);
          Edit1.Text := '';
          PassWord := '';
          Label1.Caption := '请输入密码:          ';
        end
      else
      begin
        Verified := True;
        StrPCopy(PassWord,Edit1.Text);
        Edit1.Text := '';
        Label1.Caption := '请再次输入密码:          ';
      end;
      key := #0;
  end;
end;


end.

⌨️ 快捷键说明

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