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.

效果圖:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM