Delphi 定时器之Timer1【淡出淡进效果】
发布日期:2021-05-04 14:31:04 浏览次数:25 分类:原创文章

本文共 1291 字,大约阅读时间需要 4 分钟。

RAD Studio 10.4 测试√


1、Timer的主要属性

属性 属性解释
Enabled 当值为True时,打开定时器,否则关闭定时器。默认值为true。
Interval 控制OnTimer事件触发的时间间隔,单位是毫秒。将Interval设置为0,相当于关闭定时器。默认值为1000ms(1秒)。

2、Timer的主要事件
Timer只有一个OnTimer事件。当Timer打开时,每经过Interval属性指定的时间,Timer就会触发OnTimer事件,执行其中的程序。


控件:Timer、scGPGlyphButton
代码大概的意思就是通过定时器的 Interval 来搞事情,设置scGPGlyphButton 获取焦点、鼠标移上去和失去焦点时的颜色的不透明度,达到淡出淡进的效果。

//全局变量int1,state1var  int1: Integer = 0;  state1: String = '停止';  ***************************************************************procedure TMainF.scGPGlyphButton1MouseEnter(Sender: TObject); // 鼠标进入事件begin  int1 := 0;  state1 := '开始';end;procedure TMainF.scGPGlyphButton1MouseLeave(Sender: TObject); // 鼠标离开事件begin  state1 := '停止';end;procedure TMainF.Timer1Timer(Sender: TObject);var  i: Integer;begin  i := int1;  if state1 = '开始' then  begin    if ((0 <= i) and (i < 255)) then    begin      MainF.scGPGlyphButton1.Options.HotColorAlpha := i;      i := i + 1;      Memo1.Lines.Add(IntToStr(i));      int1 := i;    end;  end  else if state1 = '停止' then  begin    if ((0 < i) and (i <= 255)) then    begin      i := i - 1;      MainF.scGPGlyphButton1.Options.NormalColorAlpha := i;      MainF.scGPGlyphButton1.Options.FocusedColorAlpha := i;      Memo1.Lines.Add(IntToStr(i) + '减去');      int1 := i;    end;  end;end;

学习中记录的一点点笔记,以便以后翻阅。

上一篇:Delphi Image之圆形头像
下一篇:CSDN 如何修改文字体及颜色

发表评论

最新留言

关注你微信了!
[***.104.42.241]2025年03月22日 13时00分28秒