Delphi Image上文字平滑移动


本文整理自网络,侵删。

 var
Form1: TForm1;
MaxTxtWindth,Y:Integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
DoubleBuffered := True;
Y := Image1.ClientWidth;
MaxTxtWindth :=Image1.Canvas.TextWidth('dg');
Image1.Transparent := True; //可以加个背景
Image1.Canvas.Font.Color:=clRed;
Timer1.Interval := 30;
Timer1.Enabled := True;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
i:Integer;
TxtLinePosY:Integer;
MyStr:WideString;
TemStr:String;
begin
Image1.Canvas.FillRect(Image1.ClientRect);
TxtLinePosY:= Y;
mystr:=edit2.Text;
for i:=1 to Length(MyStr) do
begin
Inc(TxtLinePosY,MaxTxtWindth);
TemStr:=MyStr[i];
if Ord(TemStr[1]) > 128 then
begin
MaxTxtWindth:=Image1.Canvas.TextWidth('aa');
end
else
MaxTxtWindth:=Image1.Canvas.TextWidth('a');
if (TxtLinePosY < -MaxTxtWindth)or(TxtLinePosY > Image1.ClientWidth) then
Continue
else
begin
Image1.Canvas.TextOut(TxtLinePosY,0,mystr[i]);
end;
end;
Dec(Y);
if Y < -Length(MyStr)* MaxTxtWindth then
Y := Image1.ClientWidth;
end;

相关阅读 >>

Delphi xe10 手机内部系统相关操作(手机信息、震动、剪贴板、键盘、电话、拨号)

Delphi cpu窗口的扩展学习

Delphi idhttp批量上传图片

Delphi 中文大写日期转换函数

Delphi中动态加载treeview信息

Delphi dbgrideh 的分组统计 datagrouping

Delphi of 打坐与普通攻击calll调用

Delphi windows 编程[20] - 改变菜单项并换行

Delphi 下 vclzip控件的简单使用

Delphi 微信公众平台 Delphi sdk

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...