unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls;
type
TForm1 = class(TForm)
BtnConHilo: TButton;
ProgressBar1: TProgressBar;
BtnSinHilo: TButton;
procedure BtnConHiloClick(Sender: TObject);
procedure BtnSinHiloClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2;
{$R *.dfm}
//****************************************************************
procedure TForm1.BtnConHiloClick(Sender: TObject);
var
hilo: TProgreso;
begin
hilo:= TProgreso.Create(true);
hilo.FreeOnTerminate:=true;
hilo.Resume;
end;
//****************************************************************
procedure TForm1.BtnSinHiloClick(Sender: TObject);
begin
ProgressBar1.Position:=0;
repeat
sleep(1000);
ProgressBar1.Position:=ProgressBar1.Position +1;
until
ProgressBar1.Position = ProgressBar1.Max;
end;
end.
################################
unit2.pas
################################
unit Unit2;
interface
uses
Classes, windows, unit1;
type
TProgreso = class (TThread)
protected
procedure Execute; override;
end;
implementation
//****************************************************************
procedure TProgreso.Execute;
begin
inherited;
with form1 do
begin
ProgressBar1.Position:=0;
repeat
sleep(1000);
ProgressBar1.Position:=ProgressBar1.Position +1;
until
ProgressBar1.Position = ProgressBar1.Max;
end;
end;
end.
.
sábado, 3 de junio de 2017
Suscribirse a:
Entradas (Atom)