⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 downthread.pas

📁 提取网页文件图片地址,应用此工具
💻 PAS
字号:
unit downthread;

interface

uses
  Classes,windows,messages,comCtrls,mydownfile;

type
  Tdownthread = class(TThread)
  private
    FDownFile:TmyDownFile;
    FDone:boolean;
    FUrlName:string;

    FListView:TListView;
    FitemIndex : integer;
    FFormHandle :Thandle;
       procedure UpdateListView;
    { Private declarations }
  protected
    procedure Execute; override;
  public
      Constructor create(urlName,DownDir:string;ListView:TlistView;
                itemIndex,subItemIndex,timeout:integer;Hwnd:Thandle);
      destructor Destroy; override;
  end;

implementation

{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure Tdownthread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ Tdownthread }

constructor Tdownthread.create(urlName,DownDir: string; ListView: TlistView;
  itemIndex, subItemIndex,timeout: integer;Hwnd:Thandle);
begin
  inherited create(false);
  FDownFile := TmyDownFile.create(nil);
  FDownFile.listView := listView;
  FDownFile.Hwnd := Hwnd;
  FDownFile.ItemIndex := ItemIndex;
 // FDownFile.SubItemIndex := SubItemIndex;
  FDownFile.DownDir := DownDir;
  FDownFile.SetTimeOut(Timeout);
  FUrlName:= UrlName;
  FListView := ListView;
  FitemIndex := ItemIndex;
  FFormHandle := HWnd;
end;

destructor Tdownthread.Destroy;
begin
  FDownFile.Free;
  inherited;
end;

procedure Tdownthread.Execute;
begin
  FDone := FDownFile.HttpDownLoad(FurlName,'',false);

  //  Synchronize(UpdateListView);
  { Place thread code here }
end;

procedure Tdownthread.UpdateListView;
begin
 // if FDone then
  //  begin
 //    FlistView.Items.Item[FitemIndex].SubItems.Strings[2] := '下载成功';
  // //    FlistView.Items.Item[FitemIndex].SubItemImages[2] := 4 ;
  //  end
 //  else
  //   begin
  //      FlistView.Items.Item[FitemIndex].SubItems.Strings[2] := '下载失败';
  //     FlistView.Items.Item[FitemIndex].SubItemImages[2] := 3;
  //  end;
         sendmessage(FFormHandle,WM_DONE,0,0);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -