Ver Mensaje Individual
  #7  
Antiguo 27-12-2013
n03l n03l is offline
Miembro
 
Registrado: feb 2007
Posts: 73
Reputación: 18
n03l Va por buen camino
Ok, despues de tirar puñaladas al aire y haciendo uso del copy paste e hecho lo siguiente:

En el form
Código Delphi [-]
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    BitBtn2: TBitBtn;
    ProgressBar1: TProgressBar;
    Label1: TLabel;
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;



implementation
Uses Hilos;
var
Hilo:THilo;

{$R *.dfm}

procedure TForm1.BitBtn2Click(Sender: TObject);
begin

 //Aqui no se como capturar el nombre del form sin utilizar Form1. ya
 // que el nombre es dinamico
Hilo:=THilo.Create(Form1);
Hilo.FreeOnTerminate:=true;
Hilo.Resume;
end;

end.


y en el hilo me da el siguiente error al tratar de compilarlo
[DCC Error] Hilos.pas(39): E2003 Undeclared identifier: 'ProgressBar1'

el Hilo
Código Delphi [-]
unit Hilos;

interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, Buttons;

type
  THilo = class(TThread)
  private
  FName: TForm;

    { Private declarations }
  protected
    procedure Execute; override;
     public
    constructor Create(Name: TForm);

  end;


implementation

uses Unit1;


constructor THilo.Create(Name: TForm);
begin
  inherited Create(True);
  FName := Name;
  FreeOnTerminate := True;
end;


procedure THilo.Execute;
begin


FName.ProgressBar1.Position:=0;
FName.BitBtn2.Enabled:=false;
repeat

FName.ProgressBar1.Position:=FName.ProgressBar1.Position+1;
 Sleep(500);
until FName.ProgressBar1.Position=FName.ProgressBar1.Max;

FName.BitBtn2.Enabled:=true;
end;


end.
Responder Con Cita