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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 LoadFromURL detecting a stuck download

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
bmesser Posted - Sep 21 2012 : 10:37:38
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.
3   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Sep 22 2012 : 10:01:33
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
bmesser Posted - Sep 22 2012 : 08:10:53
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.
w2m Posted - Sep 21 2012 : 12:31:27
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