下面是一个简单的列子:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
Image1: TImage;
procedure Timer1Timer(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if label1.left > 500 then
begin
label1.left:=24;
label1.top:=8;
label2.left:=499;
label2.top:=8;
image1.top:=328;
image1.left:=16;
end
else
begin
label1.left:=label1.left+30;
label1.top:=label1.top+30;
label2.left:=label2.Left-30;
label2.top:=label2.top+30;
label1.Font.Color:=label1.font.color+150;
label2.font.color:=label2.font.color+131;
image1.Left:=image1.left+30;
image1.top:=image1.top-30;
image1.Visible:=not image1.Visible;
end;
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (ssAlt in Shift) and (ssCtrl in Shift)
and (Key=VK_Tab) then application.Terminate;
end;
//屏幕保护程序规定:接收参数s 为运行,接受参数R为设置
program Project1 ;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.RES}
begin
if ParamCount>0 then
if pos('s',paramstr(1))>0 then
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end;