如何使用Label实现无闪烁走马灯效果(100分)

  • 主题发起人 主题发起人 luket_1979
  • 开始时间 开始时间
L

luket_1979

Unregistered / Unconfirmed
GUEST, unregistred user!
如何使用Label实现无闪烁走马灯效果,重谢[:(!]
 
用两个label交替,或者用StaticText1
 
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
Self.DoubleBuffered := true; //设置双缓冲最重要!
for i:= 1 to 1000 do
begin
application.ProcessMessages;
label1.Left := label1.Left + 1; //移动即可
end;
end;
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;

type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
s:string;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
s:='TEST ';
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
s:=s+copy(s,1,1);
delete(s,1,1);
label1.Caption:=s;
Label1.Refresh;
end;

end.
 
谢谢!!!
 
后退
顶部