Solved

TJPEGImage.LoadFromFile

Posted on 1999-01-02
5
344 Views
Last Modified: 2010-04-04
If the LoadFromFile fail to open a JPEG file, the program will halt and raise a exception !
As a result, how can I control this without halt the program ?

Andrew
0
Comment
Question by:andrewyu
  • 3
  • 2
5 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 0 total points
ID: 1354221
Hi Andrew,

use this one:

  try
    jpeg.LoadFromFile(...);
    result:=true;
  except result:=false end;

Regards, Madshi.
0
 

Author Comment

by:andrewyu
ID: 1354222
Thank you very much !

But, what is the exception it raise ?

Andrew
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1354223
Heh? What do you mean?

Do you want to have the exception text? Then do something like this:

  try
    ...
    result:='Everything is fine...';
  except
    if ExceptObject is Exception then
         result:=(ExceptObject as Exception).Message
    else result:='Unknown Exception...';
  end;

Regards, Madshi.
0
 

Author Comment

by:andrewyu
ID: 1354224
Yes, it exact what I meant !

Thank you very much for your help !

Andrew
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1354225
No problem...  :-)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question