Delphi中如何实现滚动文字

1、先添加一个Timer控件,其Interval属性设置为50。

2、再添加一个Label控件,Name为Label1。

3、然后在Timer的OnTimer事件添加如下代码:

 1 unit Unit13;
 2 
 3 interface
 4 
 5 uses
 6   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 7   Dialogs, StdCtrls, ExtCtrls, jpeg;
 8 
 9 type
10   TForm13 = class(TForm)
11     Timer1: TTimer;
12     Label1: TLabel;
13     Image1: TImage;
14     procedure Timer1Timer(Sender: TObject);
15   private
16     { Private declarations }
17   public
18     { Public declarations }
19   end;
20 
21 var
22   Form13: TForm13;
23 
24 implementation
25 
26 {$R *.dfm}
27 
28 procedure TForm13.Timer1Timer(Sender: TObject);
29 begin
30   Self.Label1.Left := Self.Label1.Left - 1 ;
31   if Self.Label1.Left + Self.Label1.Width = 0 then
32   Self.Label1.Left := Form13.Width;
33 
34 end;
35 
36 end.

效果图:

 

原文地址:https://www.cnblogs.com/China3S/p/3196529.html