Ver Mensaje Individual
  #2  
Antiguo 26-03-2005
Avatar de Lepe
[Lepe] Lepe is offline
Miembro Premium
 
Registrado: may 2003
Posts: 7.424
Reputación: 29
Lepe Va por buen camino
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
    { Private declarations }
    Cuenta:Integer;
  public
    { Public declarations }
  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.
Responder Con Cita