Ver Mensaje Individual
  #3  
Antiguo 16-04-2008
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Reputación: 25
Caral Va por buen camino
Hola
Este es un ejemplo de progressbar.
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure DialogTimer(Sender: TObject) ;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.DialogTimer(Sender: TObject) ;
var
   aPB : TProgressBar;
begin
   if NOT (Sender is TTimer) then Exit;

   if ((Sender as TTimer).Owner) is TForm then
   with ((Sender as TTimer).Owner) as TForm do
   begin
     aPB := TProgressBar(FindComponent('Progress')) ;

     if aPB.Position >= aPB.Max then
       ModalResult := mrCancel
     else
       aPB.StepIt;
   end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
   AMsgDialog : TForm;
   AProgressBar : TProgressBar;
   ATimer : TTimer;
begin
   AMsgDialog := CreateMessageDialog('El Programa se esta cargando, Espere', mtWarning, []) ;
   AProgressBar := TProgressBar.Create(AMsgDialog) ;
   ATimer := TTimer.Create(AMsgDialog) ;
   with AMsgDialog do
   try
    Tag := 5; // aqui se cambian los segundos

    Caption := 'En Proceso, espere';
    Height := 100;

    with AProgressBar do begin
     Name := 'Progress';
     Parent := AMsgDialog;
     Max := AMsgDialog.Tag;
     Step := 1;
     Top := 50;
     Left := 8;
     Width := AMsgDialog.ClientWidth - 16;
    end;

    with ATimer do
    begin
     Interval := 1000;
     OnTimer:=DialogTimer;
    end;

     case ShowModal of
     ID_CANCEL:
    //
    end;
   finally
    ATimer.OnTimer := nil;
    Free;
  end;
end;

end.
Saludos
Responder Con Cita