Einzelnen Beitrag anzeigen

Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#2

Re: URLDownloadtoFile abbrechen?

  Alt 17. Apr 2004, 16:46
Hi!


Implementiere IBindStatusCallback von URLDownloadToFIle (siehe z.B http://www.delphipraxis.net/internal_redirect.php?t=75)
und frage im OnProgress von IBindStatusCallback ab, ob der Abbrechen-Button angeklickt wurde (mittels Vergleich einer Boolean-Variable)

Delphi-Quellcode:
type
  TForm1 = class(TForm)
    AbbrechenButton: TButton;
   procedure AbbrechenButtonClick(Sender: TObject);
  private
    { Private declarations }
    FCancelDownLoad : Boolean;
  public
    { Public declarations }
  end;

function cDownloadStatusCallback.OnProgress(ulProgress, ulProgressMax, ulStatusCode: ULONG; szStatusText: LPCWSTR): HResult;
begin
 //....Code...
 if FCancelDownLoad then // Download abgebrochen?
  Result := E_ABORT;
 //....Code...
end;

procedure TForm1.AbbrechenButtonClick(Sender: TObject);
begin
 FCancelDownLoad := True; // Download abbrechen
end;
Thomas
  Mit Zitat antworten Zitat