Ver Mensaje Individual
  #1  
Antiguo 16-08-2005
Antuan Antuan is offline
Miembro
 
Registrado: jul 2005
Ubicación: Madrid
Posts: 73
Reputación: 19
Antuan Va por buen camino
Algo falta para activar el timer.

Ya sabeis que soy novato y no se pero algo me falta para activar en timer en el label1 sin tener que poner el componente timer graficamente en el form1.
este es el Codigo:
Código Delphi [-]
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;
type
  TForm1 = class(TForm)
    Label1: TLabel;
    procedure Timer1Timer(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    Timer1: TTimer;
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
  Contador: Integer;
implementation
{$R *.dfm}
function GetCounter(Second: Integer): string;
var
  Minute, NewSecond, Hour: Currency;
begin
  Hour       := Int(Second / 3600);
  Minute     := Int((Second - (Hour * 3600)) / 60);
  NewSecond  := Second - int(Hour * 3600 + Minute * 60);
  GetCounter := CurrToStr(Hour) + ':' + CurrToStr(Minute) + ':' + CurrToStr(NewSecond);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Timer1 := TTimer.Create(Form1);
with Timer1 do
begin
  Enabled := True;
  Interval := 1000;
  Name := 'Timer1';
  Tag := 0;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  label1.Caption := GetCounter(GetTickCount div 1000 - Contador div 1000);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 Contador := GetTickCount;
end;
end.
Y no se que me falta, para que me funcione.
Gracias
Responder Con Cita