Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Invalid Picture in Image Control?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01205569
Message ID:
01205582
Vues:
29
This message has been marked as the solution to the initial question of the thread.
Rodd,

>> How do you use LoadPicture() in tandem with the image control? What property of the >> image control receives the return value of LOADPICTURE()?

I've just tried again, and LOADPICTURE works very nicely

= LOADPICTURE("C:\GoodPicture.bmp")
= LOADPICTURE("C:\BadPicture.Bmp")
= LOADPICTURE("C:\SillyTXT.txt")

LOADPICTURE returns a OLE Error when it tries to load the TXT or a corrupted image.
So, before assigning an image file to the Image object, use a TRY/CATCH with LOADPICTURE. and trap the error.

Worked perfectly here.

In HELP, you'll find "Creates an object reference for a bitmap, icon, or Windows meta file.", but you don't need that reference, so call LOADPICTURE directly... and enjoy !

So, you can try this way:
lcImageFile = GETPICT()
TRY
   =LOADPICTURE(lcImageFile)
   WAIT WINDOW 'IMAGE IS OK'
   Thisform.Image1.Picture = lcImageFile
CATCH
   WAIT WINDOW 'ERROR LOADING IMAGE !'
ENDTRY
HTH

Cesar




>
>>Hi Rodd,
>>
>>VFP usually returns an error when an Image object receives a corrupt image file.
>>
>>So, you can use a simple TRY/CATCH and trap an error.
>>
>>You can also try using LOADPICTURE()
>>
>>
>>TRY
>>   xObj_Picture = LOADPICTURE(xCaminho_jpg)
>>   WAIT WINDOW 'IMAGE IS OK'
>>CATCH
>>   WAIT WINDOW 'ERROR LOADING IMAGE !'
>>ENDTRY
>>
>>
>>
>>Calvin Hsia also provides some suggestions on this respect:
>>http://blogs.msdn.com/calvin_hsia/archive/2005/07/24/442873.aspx
>>
>>Hope this helps
>>
>>Cesar
>>
>>
>>>I'm trying to determine if the image that I assign to the Picture value of an image control is actually being displayed. In other words, if the user selects a corrupt image file to be displayed on the form in my image control, it won't be displayed. I want to be able to trap that and provide some feedback to the user so they don't think the form isn't working.
>>>
>>>Is there a way to trap this?
>>>
>>>As far as I can tell, the image control provides no feedback regarding invalid files ... it just doesn't display the picture. I'm already checking the extension and looking at the first 4 characters of the file to try to determine if they've selected a true image file. But none of this protects against corrupted image files.
>>>
>>>I'm working in VFP 8 but could switch to 9 if there were a way to do this in 9.
>>>
>>>Thanks for any help you can provide.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform