delphi - 右滚动文字


本文整理自网络,侵删。

 
procedure TForm1.Timer2Timer(Sender: TObject);
const
{$WRITEABLECONST ON}
  ScrollingText : string = 'This is right scrolling text ';
{$WRITEABLECONST OFF}
var
  ScrollPosition: Integer;
begin
  Label2.Caption := ScrollingText;
  for ScrollPosition := (Length(ScrollingText) - 1) downto 2 do
    begin
      ScrollingText[ScrollPosition] := Label2.Caption[ScrollPosition - 1];
      ScrollingText[1] := Label2.Caption[Length(ScrollingText) - 1];
    end;
end;


但是我建议不要使用可写常量,也不要使用for循环:

procedure TForm1.FormCreate(Sender: TObject);
begin
  ...
  Label2.Caption := 'This is right scrolling text ';
end;

procedure TForm1.Timer2Timer(Sender: TObject);
var
  S: String;
begin
  S := Label2.Caption;
  S := S[Length(S)] + Copy(S, 1, Length(S) - 1);
  Label2.Caption := S;
end;

相关阅读 >>

Delphi中控制与捕捉输入法的实现单元

Delphi想tstringgrid中添加和删除行的方法

Delphi query1 导出csv txt

Delphi idtcp上传文件

Delphi遍历指定目录下指定类型文件的函数

Delphi 图像自动调整显示

Delphi combobox1dropdown 生成动态下拉列表

Delphi firemonkey 图片显示拉伸不变形

Delphi xe7上启用android蓝牙

Delphi 10.3 控件遮挡 webbrowser

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



打赏

取消

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

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

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

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

评论

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