平滑滚屏:
//main.pasunit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
Y:integer;
implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
y:=paintbox1.Height;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
PaintBox1.Canvas.Font.Color := clBlue;
PaintBox1.Canvas.TextOut(50,y,'这是平滑滚屏示例');
PaintBox1.Canvas.Font.Color := clBlack;
PaintBox1.Canvas.TextOut(60,y+PaintBox1.Canvas.Font.Size+8,'效果还不错吧');
dec(y);
if y<-(PaintBox1.Canvas.Font.Size+8)*2 then y:=paintbox1.Height;
end;procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
PaintBox1.Canvas.Font.Name:='宋体';
PaintBox1.Canvas.Font.Size:=10;
PaintBox1.Canvas.Brush.Color := clwhite;
PaintBox1.Canvas.FillRect(Rect(0,0,PaintBox1.Width, PaintBox1.Height));
end;
end.
//main.dfm
object Form1: TForm1
Left = 209
Top = 142
Width = 214
Height = 202
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object PaintBox1: TPaintBox
Left = 0
Top = 0
Width = 206
Height = 175
Align = alClient
OnPaint = PaintBox1Paint
end
object Timer1: TTimer
Interval = 50
OnTimer = Timer1Timer
Left = 152
Top = 128
end
//main.pasunit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
Y:integer;
implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
y:=paintbox1.Height;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
PaintBox1.Canvas.Font.Color := clBlue;
PaintBox1.Canvas.TextOut(50,y,'这是平滑滚屏示例');
PaintBox1.Canvas.Font.Color := clBlack;
PaintBox1.Canvas.TextOut(60,y+PaintBox1.Canvas.Font.Size+8,'效果还不错吧');
dec(y);
if y<-(PaintBox1.Canvas.Font.Size+8)*2 then y:=paintbox1.Height;
end;procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
PaintBox1.Canvas.Font.Name:='宋体';
PaintBox1.Canvas.Font.Size:=10;
PaintBox1.Canvas.Brush.Color := clwhite;
PaintBox1.Canvas.FillRect(Rect(0,0,PaintBox1.Width, PaintBox1.Height));
end;
end.
//main.dfm
object Form1: TForm1
Left = 209
Top = 142
Width = 214
Height = 202
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object PaintBox1: TPaintBox
Left = 0
Top = 0
Width = 206
Height = 175
Align = alClient
OnPaint = PaintBox1Paint
end
object Timer1: TTimer
Interval = 50
OnTimer = Timer1Timer
Left = 152
Top = 128
end
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货