Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   winnet custom download thread (https://www.delphipraxis.net/185397-winnet-custom-download-thread.html)

drama22 6. Jun 2015 19:35

winnet custom download thread
 
hello , i succsesfly create thread to downoad images with my winnet but i have problem with adding image here is my code

Delphi-Quellcode:
//this how i try to grab file url
begin
filename := 'http://forums.accuweather.com/uploads/post-13204-1336091269.gif';
Add_Item(ListView1, FileName);
end;
and this my adding item

Delphi-Quellcode:
Procedure Tform.Add_Item(ListView : TListView; strFile: String);
begin
 With TURLDownload.Create( Image1 ) do
  begin
    Memo1.Lines.Add(' Image Download Thread... @ThreadID = ' + IntToStr( ThreadID ) );
    URL := strFile;
    Resume;
  end;

  With ListView.Items.Add do
  begin
    Caption  := '';
    SubItems.Add( strCaption ); // subitem 0
    SubItems.AddObject( 'IMA', TObject( aGif ) ); // subitem 1
  end;

and this is my thread execute

Delphi-Quellcode:
procedure TURLDownload.Execute;
begin
FreeOnTerminate := True;
  if DownloadToStream
    then UpdateVisual;
end;

procedure TURLDownload.UpdateVisual;
begin
  FMS.Position := 0;
  if ExtractFileExt(Furl) = '.gif' then // if image is gif
begin
  aGIF := TGifImage.Create;
  aGIF.LoadFromStream(FMS);
  aGIF.Transparent := True;
  //FImage.Picture.Bitmap.LoadFromStream(FMS);
end;
end;
and this is my thread

Delphi-Quellcode:
  type
  TURLDownload = class(TThread)
  private
    FImage : TImage;
    FMs: TMemoryStream;
    FURL: String;
    procedure UpdateVisual;
    function DownloadToStream: Boolean;
  protected
    procedure Execute; override;
  public
    constructor Create( aImage:TImage );
    destructor Destroy; override;
  public
    property URL: String read FURL write FURL;
  end;
the problem is my application is multiable client application and Add_Item(ListView1, FileName); procedure requested each time my clients are entered to grab this images of other clients the problem is images not loaded until some client disconneceted or possibly i do the whole process in wrong way by the way aGIF : TGifImage; is a global variable

Sir Rufo 6. Jun 2015 23:21

AW: winnet custom download thread
 
You send someone to get you the car and right after this you try to enter the car and fall on your bottom. Why?

If you got the answer, you have the answer for your question here.

Afterwards you should have a look at the http://www.delphipraxis.net/185335-b...ab-xe2%5D.html


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:54 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz