Einzelnen Beitrag anzeigen

drama22

Registriert seit: 12. Jan 2013
88 Beiträge
 
#1

winnet custom download thread

  Alt 6. Jun 2015, 20:35
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) = '.gifthen // 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
  Mit Zitat antworten Zitat