- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
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.