Cesario Lababidi
asked on
UrlDownloadToFile & IBindStatusCallback
Hello Experts ;-)
I´m looking for a working exmaple how to use IBindStatusCallBack with UrlDownloadFile?
TIA
Cesario
I´m looking for a working exmaple how to use IBindStatusCallBack with UrlDownloadFile?
TIA
Cesario
What components are you using ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Nice example, Cynna !
;) Thanks simonet.
ASKER
Cynna, great example
1000 Thanx
Cesario
1000 Thanx
Cesario
ASKER
cynna,
do you have any idea how to cancel the download ?
do you have any idea how to cancel the download ?
2000 welcomes :))
OnProgress is callback function that is periodically called during download.
You can tell it through OnProgress result to abort operation. Just exit with E_ABORT result instead S_OK.
For the sake of simplicity I modified my previous example to cancel download if file is greater the 15kb. You should, of course, use class flag variable or add method or...<zillion other ways> to choose when to return E_ABORT.
OK, replace old handler with this version:
function TBindStatusCallback.OnProg ress(ulPro gress, ulProgressMax,
ulStatusCode: ULONG; szStatusText: LPCWSTR): HResult;
begin
// Do something, for example, show progress:
Form1.Caption:='Downloaded : '+IntToStr(ulProgress) +' bytes';
Result := S_OK;
// Place some abort flag here. For demo purpose here, cancel after 15K:
if ulProgress> 15000 then begin
Result := E_ABORT;
Form1.Caption:='Download aborted!'
end;
end;
OnProgress is callback function that is periodically called during download.
You can tell it through OnProgress result to abort operation. Just exit with E_ABORT result instead S_OK.
For the sake of simplicity I modified my previous example to cancel download if file is greater the 15kb. You should, of course, use class flag variable or add method or...<zillion other ways> to choose when to return E_ABORT.
OK, replace old handler with this version:
function TBindStatusCallback.OnProg
ulStatusCode: ULONG; szStatusText: LPCWSTR): HResult;
begin
// Do something, for example, show progress:
Form1.Caption:='Downloaded
Result := S_OK;
// Place some abort flag here. For demo purpose here, cancel after 15K:
if ulProgress> 15000 then begin
Result := E_ABORT;
Form1.Caption:='Download aborted!'
end;
end;