Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 15-05-2012
angelp4492 angelp4492 is offline
Miembro
 
Registrado: dic 2007
Posts: 99
Poder: 0
angelp4492 cantidad desconocida en este momento
[error] Value be beetween 0 and 65535

Hola intento crear una barra de progreso en un listview y al recibir los datos y asirnarlos al listview me sale el error Value be beetween 0 and 65535.

esta es la unidad.

Código Delphi [-]
unit Unit1;

interface

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

  type TTransferFile = class
    private
        procedure IndyInAThreadComplete(sender: TObject);
    public
     ProgressBar   : TProgressBar;
     ListView      : TListView;
     Item          : TListItem;
     Url           : string;
     Filename      : string;
     TempFilename  : string;
     Path          : string;
     UniqueID      : Integer;
     TotalFileSize: int64; // use 0 if unknown
     BytesPreviouslyDownloaded: int64; // eg. if resuming
     BytesDownloaded: int64;
     //State: TDownloadStateForImages; //para las imagenes
     IndyInAThread: TIndyInAThread;    //variable del thread
     constructor create (URL_ :string; Listview_ : TListView; unique_ID:integer);
     procedure addToView;
     procedure transferfile;
     //procedure UpdateDatos;
  end;

type
  TForm1 = class(TForm)
    ListView1: TListView;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    fNextUniqueID: integer;
    { Private declarations }
  public
    { Public declarations }
    DownloadList : TObjectList;
    function GetNextUniqueID: integer;
    function IndexOfDownloadableFile(UniqueID_: integer): integer; // returns the index of the downloadable file that matches this uniqueid
     Procedure HTTPClientDownloadBeginWork(var Msg:TMessage);Message WM_HTTPClientDownloadBeginWork;

  end;
 type TDownloadfile = class (TObject)
    private
    public
     Url           : string;
     UniqueID      : Integer;
    constructor create (URL_ :string;  uniqueID_:integer);
   end;

var
  Form1: TForm1;

implementation

 constructor TDownloadFIle.create (URL_ :string;  uniqueID_:integer);
    begin
        inherited Create;
        URL := URL_;
        UniqueID := UniqueID_;
        //State := si_Blank;

    end;

    constructor TTransferFile.create (URL_ :string; Listview_ : TListView; unique_ID:integer);
    begin
        inherited Create;
        URL := URL_;
        Listview := Listview_;
        UniqueID := Unique_ID;
        ProgressBar := TProgressBar.Create(nil);

        //State := si_Blank;

    end;
     procedure TTransferFile.IndyInAThreadComplete(sender: TObject);
  begin
      if (Sender = IndyInAThread) then
        IndyInAThread := nil;
  end;

  function Tform1.GetNextUniqueID: integer;
    begin
        result := fNextUniqueID;//obtenemos un ID por cada thread
        inc(fNextUniqueID);
    end;

function TForm1.IndexOfDownloadableFile(UniqueID_: integer): integer;
    var
        i: integer;
    begin
        result := -1;
        i := 0;
        while ( (result = -1) and (i < Downloadlist.Count) ) do
        begin
            if TDownloadFile(DownloadList[i]).UniqueID = UniqueID_ then
              result := i
            else
              inc(i);
        end;
    end;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
DownloadList:=TObjectList.Create;
fNextUniqueID:=0;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  newlistitem : TListItem;
  enlace :string;
  download : TDownloadfile;
  transferfile : TTransferfile;
  i: Integer;

begin
   enlace := 'http://www.rtve.es/resources/TE_SAMARE/mp4/6/0/1334332703906.mp4';
   download :=TDownloadfile.create(enlace,GetNextUniqueID);
   DownloadList.Add(download);
   Transferfile:= TTransferFile.create(TDownloadfile(DownloadList[0]).Url,ListView1,TDownloadfile(DownloadList[0]).UniqueID);
   transferfile.addToView;
   transferfile.transferfile;
   end;

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


//if es_descarga then Item.ImageIndex := 9
//else Item.ImageIndex := 10;

Item.Data := self;
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;
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_));
           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; aquí falla
           //ListviewTransfer.Repaint;

        end;
    end;



    procedure TTransferfile.transferfile;
begin
  Self.BytesPreviouslyDownloaded:=0;
  IndyInAThread := TIndyInAThread.Create(Self.Url,'c:\prueba.mp4',false,8080,'127.0.0.1',Self.UniqueID,form1.handle,Ind  yInAThreadComplete);
  ShowMessage(Self.Url);
end;



end.

alguien se le ocurre alguna idea de que estoy haciendo mal.
Responder Con Cita
  #2  
Antiguo 15-05-2012
luisgutierrezb luisgutierrezb is offline
Miembro
 
Registrado: oct 2005
Ubicación: México
Posts: 925
Poder: 19
luisgutierrezb Va por buen camino
Pues que de seguro el total del archivo debe ser mayor a 65535, lo que puedes hacer es dividir el tamaño del archivo entre 100, y cada vez que pase esa cantidad de bytes, aumentas en el progress bar
Responder Con Cita
  #3  
Antiguo 15-05-2012
angelp4492 angelp4492 is offline
Miembro
 
Registrado: dic 2007
Posts: 99
Poder: 0
angelp4492 cantidad desconocida en este momento
Cita:
Empezado por luisgutierrezb Ver Mensaje
Pues que de seguro el total del archivo debe ser mayor a 65535, lo que puedes hacer es dividir el tamaño del archivo entre 100, y cada vez que pase esa cantidad de bytes, aumentas en el progress bar
Si pero porqué cuando coloco un progresbar en el formulario si me acepta valores mayores de 65535, y sin embargo creándolo desde una clase no?
Responder Con Cita
  #4  
Antiguo 16-05-2012
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Cita:
Empezado por angelp4492 Ver Mensaje
Si pero porqué cuando coloco un progresbar en el formulario si me acepta valores mayores de 65535, y sin embargo creándolo desde una clase no?
Hola angelp4492.

No creo que ese sea el motivo.

Para verificar que, independientemente de donde se lo cree, acepta el máximo valor posible para una propiedad de tipo Integer podés hacer:
Código Delphi [-]
...
type
  TDummyClass = class(TObject)
  public
    ProgressBar: TProgressBar;
    constructor Create(AOwner: TComponent);
    destructor Destroy;
  end;
  TForm1 = class(TForm)
  ...

implementation

{ TDummyClass }
constructor TDummyClass.Create(AOwner: TComponent);
begin
  inherited Create;
  ProgressBar:= TProgressBar.Create(nil);
  ProgressBar.Max:= MaxInt
end;

destructor TDummyClass.Destroy;
begin
  ProgressBar.Free;
  inherited Destroy
end;

{ TForm1 } 
procedure TForm1.Button1Click(Sender: TObject);
var
  DC: TDummyClass;
begin
  DC:= TDummyClass.Create(Self);
  try
   //...
   DC.ProgressBar.Parent:= Self;
   ShowMessage(IntToStr(DC.ProgressBar.Max))
  finally
    DC.Free
  end
end;
...

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 16-05-2012 a las 11:48:12.
Responder Con Cita
  #5  
Antiguo 16-05-2012
angelp4492 angelp4492 is offline
Miembro
 
Registrado: dic 2007
Posts: 99
Poder: 0
angelp4492 cantidad desconocida en este momento
Ya lo tengo resuelto no estaba operando bien entre la clase tdownloadfile y ttransferfile, ahora ya si corre la barra de progreso y me acepta valores mayores de 65535. Gracias

Última edición por angelp4492 fecha: 16-05-2012 a las 12:18:38.
Responder Con Cita
Respuesta



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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Por qué sale el [Fatal Error]Internal Error:LA30?? Lizette Varios 13 14-01-2016 13:44:35
error en la prueba de conexion al inicializar al proveedor. error de autenticacion ygeraldino Conexión con bases de datos 12 20-06-2011 23:51:18
Error al generar instalador con installshield (error 6173) jangel_ramirezm Varios 4 09-12-2008 00:07:54
Error General Sql Error lock conflict ...deadlock Patricio Varios 1 19-03-2008 14:52:14
error:[Fatal Error] Unit1.pas(7): Unit ZDbcConnection was compiled with a different.. karaoke Conexión con bases de datos 2 19-12-2007 10:22:36


La franja horaria es GMT +2. Ahora son las 15:24:01.


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