delphi timer 缓慢停止的效果
时间:2011-09-26
来源:互联网
一个文本内容在label中滚动,当我按下停止时,time缓慢的停止,就是文本的内容慢慢的挺下来,这个要怎么实现,求高手解答。。
作者: pokm098 发布时间: 2011-09-26
设一个自增变量i,可以用一个label和panle组合实现,通常label 从panel顶移到panel底,然后重新回到顶端,移动写在timer里,位置移动变量i,点击停止后i自减,也就是看起来移动速度慢了,方法不便,一直到i小于某个数值后,label不再移动停在panel中央,i重置,timer停止,搞定
作者: funxu 发布时间: 2011-09-26
panel为一个label大小,无边框
label同上,透明
label同上,透明
作者: funxu 发布时间: 2011-09-26
Delphi(Pascal) code
窗体
Delphi(Pascal) code
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.
窗体
Delphi(Pascal) code
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
作者: warrially 发布时间: 2011-09-26
#3楼 得分:0回复于:2011-09-26 14:32:59Delphi(Pascal) code
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.
窗体
Delphi(Pascal) codeobject 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
这一段是什么意思?? 背景也跟着移动了
作者: pokm098 发布时间: 2011-09-26
运行一下不就知道了
给你的是思路啊.
给你的是思路啊.
作者: warrially 发布时间: 2011-09-26
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28