这是斑竹的作品,在form上有一个timer和一个button:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
Bmp :TBitmap;
S :String;
i,Wid,Len :Integer;
begin
S :='卷起千堆雪';
Bmp :=TBitmap.Create;
SetBKMode(Bmp.Canvas.Handle,TRANSPARENT);
Bmp.Canvas.Font.Size :=72;
Bmp.Canvas.Font.Color :=RGB(Random(255),Random(255),Random(255));
Wid :=Trunc(Canvas.TextWidth(S)*9.5);
Len :=Canvas.TextHeight(S)*9;
Bmp.Width :=Wid;
Bmp.Height :=Len;
Bmp.Canvas.Brush.Color :=clBtnFace;
Bmp.Canvas.Rectangle(0,0,Bmp.Width,Bmp.Height);
Bmp.Canvas.TextOut(0,0,S);
for i :=0 to Wid-1 do
begin
Canvas.CopyRect(Rect(0,0,i,Bmp.Height-1),Bmp.Canvas,Rect(1,0,i,Bmp.Height-1));
Sleep(10);
end;
Bmp.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true;
end;
end.