试一下
unit Unit1;
interface
uses
Types,Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls, StdCtrls, ImgList;
type
TForm1 = class(TForm)
Label1: TLabel;
Timer1: TTimer;
Image1: TImage;
i1: TImageList;
Label3: TLabel;
Label2: TLabel;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
img:TImage;
i:integer;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
r,r1:TRect;
begin
//image1为背景图片
//image1.visible:=false;
//label1.visible:=false;
//label2.visible:=false;
//不闪烁的关键是所有操作先在img上进行(label1,label2不可见),最后一次制到窗体
img.Width :=image1.Width ;
img.Height :=image1.Height;
label1.Left :=(label1.Left +1);
label2.Left:=label1.Left +1;
label3.Left :=label1.left;//单纯移动方法1(闪烁)
self.Canvas.Font.Assign(label3.Font);
self.Canvas.TextOut(label3.Left ,label3.Top-60,label3.Caption);//单纯移动方法2(闪烁)
if label1.Left> self.Width then label1.Left:=-label1.Width-i1.Width;
r.TopLeft:=point(0,0);
r.BottomRight:=point(image1.Width ,image1.Height);
r1.TopLeft:=point(0,0);
r1.BottomRight:=point(image1.Picture.Width ,image1.Picture.Height);
img.Canvas.Brush.Style :=bsClear;
img.Canvas.CopyMode:=cmSrcCopy;
//img.Canvas.CopyRect(r,image1.Canvas ,r1);
img.Canvas.StretchDraw(r, image1.Picture.Graphic);
i1.Draw(img.Canvas,label1.left+label1.Width,label1.Top,i div 4);
//特殊方法(不闪烁)
img.Canvas.Font.Assign(label2.Font);
img.Canvas.TextOut(label2.Left ,label2.Top,label2.Caption);
img.Canvas.Font.Assign(label1.Font);
img.Canvas.TextOut(label1.Left ,label1.Top,label1.Caption);
self.Canvas.CopyRect(r,img.Canvas ,r);
i:=(i+1) mod 32;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
img:=TImage.Create(self);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
img.Free;
end;
end.