本文整理自网络,侵删。
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 利用tidencodermime tiddecodermime 组件字符串加密解密
Delphi tms web core tedit编辑输入框属性展示
更多相关阅读请进入《Delphi》频道 >>