|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
//看了小甲鱼的视频,随兴改进一点点
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg, StdCtrls, DateUtils;
type
TForm1 = class(TForm)
img1: TImage;
tmr1: TTimer;
tmr2: TTimer;
edt1: TEdit;
btn1: TButton;
lbl1: TLabel;
chk1: TCheckBox;
pnl1: TPanel;
lbl4: TLabel;
lbl2: TLabel;
lbl3: TLabel;
edt4: TEdit;
edt2: TEdit;
edt3: TEdit;
btn3: TButton;
btn4: TButton;
btn2: TButton;
procedure tmr1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btn1Click(Sender: TObject);
procedure tmr2Timer(Sender: TObject);
procedure chk1Click(Sender: TObject);
procedure edt1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btn2Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
procedure btn4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
password: string= '';
implementation
var
n: Integer= 3;
flag: Boolean= True;
t1,t2: Int64;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(edt1.Handle, GWL_STYLE, GetWindowLong(edt1.Handle, GWL_STYLE) or
ES_CENTER);
edt1.Invalidate;
img1.Left:= 0;
img1.Top:= 0;
img1.Align:= alClient;
edt1.Visible:= False;
btn1.Visible:= False;
btn2.Visible:= False;
edt1.PasswordChar:= '*';
chk1.Visible:= False;
tmr2.Enabled:= False;
pnl1.Visible:= False;
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
t2:= DateTimeToUnix(Now);
if flag = True then
begin
if Key = VK_RETURN then
begin
edt1.Visible:= True;
btn1.Visible:= True;
btn2.Visible:= True;
chk1.Visible:= True;
edt1.Left:= (img1.Width - edt1.Width - chk1.Width) div 2;
edt1.Top:= Trunc(img1.Height * 0.75) ;
btn1.Left:= edt1.Left;
btn1.Top:= edt1.Top + 50;
btn2.Left:= btn1.Left + btn1.Width + 10;
btn2.Top:= btn1.Top;
chk1.Left:= edt1.Left + edt1.Width + 10;
chk1.Top:= edt1.Top + 5;
edt1.SetFocus;
end
else
Application.MessageBox('请按"ENTER"键输入密码解锁屏幕!', '提示',
MB_OK or MB_ICONINFORMATION);
end
else
begin
MessageBox(Handle,
PChar('密码错误次数太多已锁定,' + IntToStr(9-t2+t1) + '秒后解锁'),
'警告', MB_OK or MB_ICONWARNING);
end;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
n:= n - 1;
if edt1.Text = password then
Close
else
begin
if n < 1 then
begin
MessageBox(Handle, '密码错误次数太多已锁定,10秒后解锁', '警告',
MB_OK + MB_ICONWARNING + MB_DEFBUTTON1);
edt1.Visible:= False;
btn1.Visible:= False;
btn2.Visible:= False;
chk1.Visible:= False;
flag:= False;
tmr2.Enabled:= True;
t1:= DateTimeToUnix(Now);
end
else
MessageBox(Handle, PChar('密码错误,您还有' + IntToStr(n) + '次机会'),
'警告', MB_OK + MB_ICONINFORMATION + MB_DEFBUTTON1);
end;
end;
procedure TForm1.tmr1Timer(Sender: TObject);
begin
SetWindowPos(Handle, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE+SWP_NOSIZE);
lbl1.Left:= 20 + Random(1000);
lbl1.Top:= 20 + Random(880);
lbl1.Font.Size:= 10 + Random(20);
case Random(5) of
0:
begin
lbl1.Font.Color:= clMaroon;
lbl1.Color:= clWhite;
end;
1:
begin
lbl1.Font.Color:= clNavy;
lbl1.Color:= clGray;
end;
2:
begin
lbl1.Font.Color:= clOlive;
lbl1.Color:= clMaroon;
end;
3:
begin
lbl1.Font.Color:= clRed;
lbl1.Color:= clPurple;
end;
4:
begin
lbl1.Font.Color:= clGreen;
lbl1.Color:= clMaroon;
end;
5:
begin
lbl1.Font.Color:= clPurple;
lbl1.Color:= clFuchsia;
end;
end;
end;
procedure TForm1.tmr2Timer(Sender: TObject);
begin
flag:= True;
n:= 3;
tmr2.Enabled:= False;
end;
procedure TForm1.chk1Click(Sender: TObject);
begin
if chk1.Checked then
edt1.PasswordChar:= #0
else
edt1.PasswordChar:= '*';
end;
procedure TForm1.edt1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = 13 then
btn1Click(Form1.btn1);
end;
procedure TForm1.btn2Click(Sender: TObject);
begin
pnl1.Visible:= True;
pnl1.Left:= Trunc((Screen.Width - pnl1.Width) * 0.5);
pnl1.Top:= Trunc(Screen.Height * 0.5);
end;
procedure TForm1.btn3Click(Sender: TObject);
begin
pnl1.Visible:= False;
end;
procedure TForm1.btn4Click(Sender: TObject);
begin
if edt2.Text = password then
begin
if edt3.Text = edt4.Text then
begin
password:= edt3.text;
MessageBox(Handle, '密码修改成功!', '提示',
MB_OK + MB_ICONINFORMATION);
pnl1.Visible:= False;
end
else
MessageBox(Handle, '两次输入的密码不一致!', '提示',
MB_OK + MB_ICONINFORMATION);
end
else
MessageBox(Handle, '原密码不正确!', '提示', MB_OK + MB_ICONINFORMATION);
end;
end.
|
|