| View previous topic :: View next topic |
| Author |
Message |
Prabhu S Guest
|
Posted: Thu Dec 08, 2005 10:24 am Post subject: Open Picture Dialog Box fails in opening invalid BMP file |
|
|
Hi,
I used Inbuilt Open Picture Dialog Box. I set the Filter Property of Open Picture Dialog Box to *.bmp
I'm able to open a valid BMP file. But if a open an invalid BMP file, an exception is generated saying "Project Project1.exe raised an exception class EInvalidGraphic".
The code which I wrote,
if(OpenPictureDialog1->Execute())
{
filename = OpenPictureDialog1->FileName;
}
When I debugged, the control is not comming to the statement
"filename = OpenPictureDialog1->FileName;"
It is getting failed in the statement "OpenPictureDialog1->Execute()".
Why the exception is generated ? How to Solve it ?
Thank you.
Regards,
Prabhu S
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Thu Dec 08, 2005 11:38 am Post subject: Re: Open Picture Dialog Box fails in opening invalid BMP fil |
|
|
Prabhu S wrote:
| Quote: | Why the exception is generated ?
|
Because the file is an not a proper .bmp file.
What do you want to solve ? How do you want your program
to behave ?
You could place a try-catch blok around the code and
use ShowMessage in the catch to tell the user
that something is wrong with the file.
Hans.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Dec 08, 2005 6:32 pm Post subject: Re: Open Picture Dialog Box fails in opening invalid BMP fil |
|
|
"Prabhu S" <prabhus (AT) tataelxsi (DOT) co.in> wrote
| Quote: | "Project Project1.exe raised an exception class EInvalidGraphic".
|
It looks like you are running your program inside the IDE debugger. In
which case, what you describe is perfectly normal. TBitmap is throwing the
exception when trying to display a preview of the invalid file.
TOpenPictureDialog will handle the exception internally and ignore the file.
The only reason you see the exception at all is because the debugger dispays
all exceptions. Simply press F9 to continue. The exception will never
reach your code.
Gambit
|
|
| Back to top |
|
 |
|