Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #20  
Antiguo 24-05-2005
Avatar de Crandel
[Crandel] Crandel is offline
Miembro Premium
 
Registrado: may 2003
Ubicación: Parana, Argentina
Posts: 1.475
Poder: 25
Crandel Va por buen camino
Post

Aca te adapte un ejemplo que tenía para que funcione como componente.
Probalo.
Te podes basar en él para el tuyo.

Código Delphi [-]
unit ProgressThread;

interface

uses
  Classes, SysUtils, ComCtrls;

type

  TProgressThread = class(TThread)
  private
    Progreso: Word;
    blnStop: Boolean;
    procedure UpdateControl;
  protected
    procedure Execute; override;
  public
    Progress: TComponent;
    procedure Stop;
  end;


  TProgressAutoInc = class(TProgressBar)
  private
    FActivo: Boolean;
    Thread: TProgressThread;
  public
    property Activo: boolean read FActivo;
    constructor Create(AOwner: TComponent); override;
    procedure Play;
    procedure Stop;
  end;


procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TProgressAutoInc]);
end;

procedure TProgressThread.Execute;
begin
  if (Progress is TProgressBar) then
    with Progress as TProgressBar do
      Progreso := Position;
  blnStop := False;
  while ( (not blnStop) and (not Terminated) and (Progreso<=100) ) do
  begin
    Inc(Progreso);
    Synchronize(UpdateControl);
    Sleep(50);
    if Progreso=100 then Progreso := 0;
  end;
end;

procedure TProgressThread.Stop;
begin
  blnStop := True;
end;

procedure TProgressThread.UpdateControl;
begin
  if (Progress is TProgressBar) then
    with Progress as TProgressBar do
      Position := Progreso;
end;

procedure TProgressAutoInc.Play;
begin
  Thread := TProgressThread.Create(true);
  with Thread do
  begin
    Progress := Self;
    FreeOnTerminate := true;
    Priority := tpNormal;
  end;
  Thread.Resume;
  FActivo := true;
end;

procedure TProgressAutoInc.Stop;
begin
  if FActivo then
    Thread.Stop;
  FActivo := false;
end;

constructor TProgressAutoInc.Create(AOwner: TComponent);
begin
  inherited create(AOwner);
  FActivo := false;
end;

end.
__________________
[Crandel]

Última edición por Crandel fecha: 24-05-2005 a las 00:24:07.
Responder Con Cita
 



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 04:41:02.


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