作者在 2010-01-25 17:33:23 发布以下内容
unit MainUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, JPEG;
type
TMainForm = class(TForm)
Image1: TImage;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Image1Click(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
AppPath: String;
i: Integer;
const sCount= 3; //设置屏保图片总数
implementation
uses PWFormUnit;
{$R *.DFM}
procedure TMainForm.Timer1Timer(Sender: TObject); //设置屏保图片循环
begin
if i< sCount then
begin
i:= i+ 1;
Image1.Picture.LoadFromFile(AppPath+ IntToStr(i)+ '.jpg'); //读取屏保图片
end
else
i:= 0;
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
i:= 0;
AppPath:= ExtractFilePath(ParamStr(0));
Image1.Picture.LoadFromFile(AppPath+ '3.jpg');
ShowCursor(False); //隐藏鼠标
end;
procedure TMainForm.Image1Click(Sender: TObject);
begin
Application.CreateForm(TPWForm, PWForm);
PWForm.ShowModal;
PWForm.Free;
ShowCurSor(True); //显示鼠标
end;
procedure TMainForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
Application.CreateForm(TPWForm, PWForm);
PWForm.ShowModal;
PWForm.Free;
ShowCurSor(True);
end;
procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if(Key=VK_F4) and ([ssAlt]=shift) then //屏蔽Alt+F4键让程序不能被关闭
Key:=0;
end;
end.
-------------------------------------
unit PWFormUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TPWForm = class(TForm)
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
PWForm: TPWForm;
implementation
uses MainUnit;
{$R *.DFM}
procedure TPWForm.Button1Click(Sender: TObject);
begin
if Edit1.Text= 'cpcw' then
MainForm.Close
else
ShowMessage('请输入正确的密码!');
end;
procedure TPWForm.Button2Click(Sender: TObject);
begin
PWForm.Close;
ShowCurSor(False);
end;
procedure TPWForm.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Key= Chr(13) then
if Edit1.Text= 'cpcw' then
MainForm.Close
else
ShowMessage('请输入正确的密码!');
end;
end.