File --> New --> project
- Necesitas un label, un timer y un botón puestos en la ventana
El código es este:
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
Cuenta:Integer;
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Cuenta := 59;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:= Format('Restan %d segundos',[cuenta]);
Timer1.Enabled:= True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Dec(Cuenta);
Label1.Caption:= Format('Restan %d segundos',[cuenta]);
if Cuenta = 0 then
begin
label1.caption := 'TIEMPO FINALIZADO';
Timer1.Enabled:= False;
ShowMessage('Aqui debes apagar el sistema');
end;
end;
end.