Tema: Multithread
Ver Mensaje Individual
  #6  
Antiguo 15-05-2012
angelp4492 angelp4492 is offline
Miembro
 
Registrado: dic 2007
Posts: 99
Reputación: 0
angelp4492 cantidad desconocida en este momento
Siguiendo unos ejemplos que hay por la red y cambiando la forma que el thread manda información, usando WM_USER, me he creado una clase para controlor el thread.

En la recepción del mensaje del thread tengo esto.

Código Delphi [-]
Procedure Tform1.HTTPClientDownloadBeginWork(var Msg:TMessage);
    var
        uniqueid_: integer;
        totalbytes_: integer;
        i: integer;
    begin
        uniqueid_ := Msg.wparam;
        totalbytes_ := Msg.LParam;

        i := IndexOfDownloadableFile(uniqueid_);
        if i <> -1 then
        begin

           //ShowMessage(IntToStr(totalbytes_));
           form1.ProgressBar1.Position:=0;
           form1.ProgressBar1.Max:=totalbytes_;
           TTransferFile(DownloadList[i]).BytesDownloaded := TTransferFile(DownloadList[i]).BytesPreviouslyDownloaded;
           TTransferFile(DownloadList[i]).TotalFileSize := TTransferFile(DownloadList[i]).BytesPreviouslyDownloaded + totalbytes_;
           //TDownloadFile(DownloadaList[i]).State := si_Downloading_Animation1;
           TTransferFile(DownloadList[i]).ProgressBar.Position := 0;
           TTransferFile(DownloadList[i]).ProgressBar.Max := TTransferFile(downloadlist[i]).TotalFileSize;
           ListviewTransfer.Repaint;

        end;
    end;

donde TTransferfile y Tdownload file son clases para manejar la descarga y downloadlist una variable de tipo objectlist. el progressbar lo creo de esta manera.

Código Delphi [-]

procedure TTransferFile.addToView;
var
  RectProg: TRect;
begin
item := ListView.items.add;
item.Caption := Url;
Item.SubItems.Add('0 kb/s');
Item.SubItems.Add('');


//if es_descarga then Item.ImageIndex := 9
//else Item.ImageIndex := 10;
ProgressBar := TsProgressBar.Create(nil);
Item.Data := ProgressBar;
RectProg := Item.DisplayRect(drBounds);
RectProg.Left := RectProg.Left + ListView.Columns[0].Width;
RectProg.Right := RectProg.Left + ListView.Columns[1].Width;
ProgressBar.BoundsRect := RectProg;
progressBar.Parent := ListView;

end;
.

En totalbytes_ tengo el tamaño del fichero en bytes, el progressbar1 componente normal me lo acepta si problemas cuando pongo form1.progressbar1.max=totalbytes_

El problema que tengo es en esta linea

TTransferFile(DownloadList[i]).ProgressBar.Max := TTransferFile(downloadlist[i]).TotalFileSize;

me sale un error que solo acepta entre 0 y 65536. Alguna Idea.
Responder Con Cita