Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 16-08-2005
Antuan Antuan is offline
Miembro
 
Registrado: jul 2005
Ubicación: Madrid
Posts: 73
Poder: 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
  #2  
Antiguo 16-08-2005
Avatar de German
German German is offline
Miembro
 
Registrado: may 2003
Ubicación: Barcelona - España
Posts: 133
Poder: 22
German Va por buen camino
Código Delphi [-]
with Timer1 do
begin
  Interval := 1000;
  onTimer := Timer1Timer;
  Enabled := True;
end;

Salu2
__________________
Tengo las manos llenas de dedos... Tengo los dedos llenos de teclas...
Tengo las teclas desordenadas... Tengo el desorden muy controlado...
Tengo el control en mis manos.
Responder Con Cita
  #3  
Antiguo 16-08-2005
Antuan Antuan is offline
Miembro
 
Registrado: jul 2005
Ubicación: Madrid
Posts: 73
Poder: 19
Antuan Va por buen camino
Ahora otra cosita si puede ser

Tengo el reloj funcionando y cualdo alcanza un tiempo presento un mensaje.
Como vuelvo a ponerlo a '0'
Código Delphi [-]
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  label1.Caption := GetCounter(GetTickCount div 1000 - Contador div 1000);
  Tiempo := GetCounter(GetTickCount div 1000 - Contador div 1000);
  If Tiempo = '0:0:30' then
  ShowMessage( 'Esto es una prueba')
end;
Muchas gracias por vuestras respuestas
Responder Con Cita
  #4  
Antiguo 16-08-2005
Avatar de jmariano
jmariano jmariano is offline
Miembro
 
Registrado: jul 2005
Posts: 376
Poder: 19
jmariano Va por buen camino
Saludos!

Podrías volver a igualar la variable "Contador" al valor de la función "GetTickCount" (como haces en el evento "OnCreate" del formulario) en la misma sentencia "If" (donde muestras el mensaje) para así volver a contar la diferencia de tiempo transcurrido.

Código Delphi [-]
procedure TForm1.Timer1Timer(Sender: TObject);
begin 
  label1.Caption := GetCounter(GetTickCount div 1000 - Contador div 1000); 
  Tiempo := GetCounter(GetTickCount div 1000 - Contador div 1000); 
  
  If Tiempo = '0:0:30' then 
  begin 
    ShowMessage( 'Esto es una prueba'); 
    Contador := GetTickCount; 
  end;
end;

Chao!

Última edición por jmariano fecha: 16-08-2005 a las 15:02:21.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 08:10:54.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi