Delphi 实现窗体倒计时进度条显示


本文整理自网络,侵删。

 
演示:



unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls, Vcl.ExtCtrls;

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

var
  Form1: TForm1;
  Limit: Integer;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Limit:= 10;
  Label1.Caption:= '离定时期限还有'+IntToStr(Limit)+'秒..';
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if Limit<=0 then
  begin
    Timer1.Enabled:= False;
    Close;
  end
  else
  begin
    ProgressBar1.Position:= 30-Limit;
    Label1.Caption:= '离定时期限还有'+IntToStr(Limit)+'秒..';
    Dec(Limit);
  end;
end;

end.

相关阅读 >>

Delphi 主窗体最小化时不显示在任务栏

Delphi 代码查询一个json ip 地址的归属地

Delphi tstringlist的用法

Delphi 按钮躲避鼠标点击

Delphi 以低用户权限启动一个进程.比如vista或者win7中的ie

Delphi使用xmlhttp组件代码

Delphi中复制线程

常用的几个网络函数和系统函数

Delphi获取进程和模块信息

Delphi 创建win桌面快捷方式,实现360桌面图标数字提示 或 类似安卓的右上角的数字提示

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...