Board index » cppbuilder » Open Picture Dialog Box fails while opening invalid file

Open Picture Dialog Box fails while opening invalid file


2005-12-08 06:22:47 PM
cppbuilder58
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
 
 

Re:Open Picture Dialog Box fails while opening invalid file

"Prabhu S" < XXXX@XXXXX.COM >wrote:
Quote

[...] Why the exception is generated ?
Because it's an invalid image file.
Quote
How to Solve it ?
You can't stop it from happening but you can account for it
when it does by using a try/catch block. for example:
filename = "";
try
{
if( OpenPictureDialog1->Execute() )
{
filename = OpenPictureDialog1->FileName;
}
}
catch( Exception &E )
{
}
if( !filename.IsEmpty() )
{
//
}
~ JD
 

Re:Open Picture Dialog Box fails while opening invalid file

"Prabhu S" < XXXX@XXXXX.COM >wrote in message
Quote
I used Inbuilt Open Picture Dialog Box.
<snip>
Please do not cross-post. It is against Borland's newsgroup guidelines
(info.borland.com/newsgroups). Post your questions only to the
single most appropriate newsgroup.
Your question was answered in the .graphics newsgroup.
Gambit
 

{smallsort}