ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 LoadFromURL detecting a stuck download
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
224 Posts

Posted - Sep 21 2012 :  10:37:38  Show Profile  Reply
Hi

I am using LoadFromURL to display an image from the internet using a URL. The component works fine but occasionally I get a download that gets stuck. I can tell that it fails because I monitor the OnProgress event and it never gets to 100% and neither does the OnFinishWork get triggered. I just wonder if there is a hidden timeout property I can use? or do I have to call my own timer to try and detect a download that never makes it?

I notice that an invalid URL does seem to trigger the OnWorkFinish but obviously no image has been received.

Bruce.

w2m

USA
1990 Posts

Posted - Sep 21 2012 :  12:31:27  Show Profile  Reply
Failure of LoadFromURL can be detected by looking at the Aborting value.

ImageEnMView LoadFromURL Error detection:
procedure TForm1.LoadFromURL1Click(Sender: TObject);
var
  iURL: string;
begin
  iCount := ImageEnMView1.ImageCount;
  iURL := 'http://www.xequte.com/imageen/graphics/page/logo.gf';
  // the correct url is http://www.xequte.com/imageen/graphics/page/logo.gif
  ImageEnMView1.MIO.LoadFromURL(iURL);
  if ImageEnMView1.MIO.Aborting then
    MessageBox(0, PWideChar('URL image ' + iURL + 'could not be found'), 'Warning', MB_ICONWARNING or MB_OK);
end;


ImageEnView LoadFromURL Error detection:
procedure TForm1.LoadFromURL1Click(Sender: TObject);
var
  iURL: string;
begin
  iURL := 'http://www.xequte.com/imageen/graphics/page/logo.gf';
  // the correct url is http://www.xequte.com/imageen/graphics/page/logo.gif
  ImageEnView1.IO.LoadFromURL(iURL);
  if ImageEnView1.IO.Aborting then
    MessageBox(0, PWideChar('URL image ' + iURL + 'could not be found.'), 'Warning', MB_ICONWARNING or MB_OK)
  else
    ImageEnView1.Update;
end;

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

bmesser

United Kingdom
224 Posts

Posted - Sep 22 2012 :  08:10:53  Show Profile  Reply
Hi

Thanks for your prompt reply.

That works great - I didn't even realise that you could check if the event had succeeded. What about setting a timeout to give up on a download? The TMS TWebImage has such a setting but I know the component is not as rich in functionality as the TImageEnMView is.

Is it possible to call another webcam image with another call to ImageEnMView.MIO.LoadFromURL(...) and add it to the existing image?

Bruce.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Sep 22 2012 :  10:01:33  Show Profile  Reply
I do not see how a timer will help unless the provided url changes so that an image is returned, but you can check for errors and prompt to change the url:

procedure TForm1.LoadFromURL1Click(Sender: TObject);
var
  iURL: string;
  iResult: boolean;
begin
  iURL := 'http://www.xequte.com/imageen/graphics/page/logo.gf';
  // the correct url is http://www.xequte.com/imageen/graphics/page/logo.gif
  // repeat until url is loaded or canceled
  repeat
    ImageEnView1.IO.Aborting := False;
    ImageEnView1.IO.LoadFromURL(iURL);
    if Fit1.Checked then
      ImageEnView1.Fit;
    iResult := ImageEnView1.IO.Aborting;
    if ImageEnView1.IO.Aborting then
      if MessageBox(0, PWideChar('URL image could not be found.  Do you want to correct the url?'), 'Warning', MB_ICONWARNING or
        MB_YESNO) = mrYes then
        iResult := InputQuery('URL', 'Edit the URL to the image', iURL)
      else
        iResult := False;
  until
    iResult = False;
end;


William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: