delphi timer 缓慢停止的效果
一个文本内容在label中滚动,当我按下停止时,time缓慢的停止,就是文本的内容慢慢的挺下来,这个要怎么实现,求高手解答。。
[解决办法]
设一个自增变量i,可以用一个label和panle组合实现,通常label 从panel顶移到panel底,然后重新回到顶端,移动写在timer里,位置移动变量i,点击停止后i自减,也就是看起来移动速度慢了,方法不便,一直到i小于某个数值后,label不再移动停在panel中央,i重置,timer停止,搞定
[解决办法]
panel为一个label大小,无边框
label同上,透明
[解决办法]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Speed: Single = 1.0;
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Speed := 1.1;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Interval := 25 ;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Interval := Round(Timer1.Interval * Speed );
if Timer1.Interval > 1000 then
Timer1.Enabled := False;
Label1.Left := Label1.Left + 2;
end;
end.
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 243
ClientWidth = 472
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 24
Top = 56
Width = 31
Height = 13
Caption = 'Label1'
end
object Button1: TButton
Left = 32
Top = 0
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object Timer1: TTimer
OnTimer = Timer1Timer
Left = 344
Top = 8
end
end