Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP6 Errors in imagecontrol

Status
Not open for further replies.

button71

Programmer
Nov 8, 2006
69
AU
I am trying to trap errors in the imagecontrol used in container in a form on my picture viewing application caused by certain image files which give a C000005 error - I guess it is unreasonable to expect the following code preventing that problem


Code:
lTableError = .f.

thisform.container1.imgcontrol1.Picture = (mypicture)

IF lTableError = .t.

    DO errmsg

ENDIF


Any ideas of how to trap a C000005 error?

As an aside the image shows OK in Irfanview when x2 clicked.

Regards

william
 
What exactly is (mypicture)? Is that a file name? Maybe this will give you some ideas:

Code:
lTableError = .f.

ON ERROR lTableError = .T.

thisform.container1.imgcontrol1.Picture = LOADPICTURE("c:\mypicture.bmp")

IF lTableError

    DO errmsg

ENDIF

Andy
 
IMO there is no way to trap or rectify, if its a C000005 error... But I could be wrong

Why not put your error routine in the imagecontrol Error event?
some thing like:

Code:
*** Image1.Init()
This.Picture = sitdoen.tiff
*this does not exist & also is a syntax error

****Image1.error()
Lparameters nError, cMethod, nLine
If nError > 0
   This.Picture = "\imaginecorp\graphics\truck1.bmp"
   *** an alternate picture
Endif

I do not know if this will work for a C000005 as if I remember correct, its accessing memory something...sorry its late... can not remember
 
Andy,

Unfortunately that modification to my code appears not to be valid and did not run

Thanks

William
 
William,

You said:
Unfortunately that modification to my code appears not to be valid and did not run

The point of Andy's code was to detect if there was any corruption in the image file. The fact that the code did not run is itself useful information.

You don't say how] the code failed to run, but it does seem to point in the direction of a corrupted file.

On a more general point, you can't error-trap a C000005 error, so I'm afraid Imaginecorp's solution won't help. Once a C000005 has been generated, the whole environment has become unstable and you can't rely on your code to do anything useful.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
On a more general point, you can't error-trap a C000005 error, so I'm afraid Imaginecorp's solution won't help. Once a C000005 has been generated, the whole environment has become unstable and you can't rely on your code to do anything useful.
Thats what I was afraid of... but then again maybe someone has come up with a way.

William:
I have experienced this error rarely, and only when a class is being debugged at run time or a COM object is corrupted... If that is any clue.
I think you should be more concerned with eliminating what is causing this error, rather than trying to trap it.
 
Imaginecorp said:
I think you should be more concerned with eliminating what is causing this error, rather than trying to trap it.

I agree. And one way to do that would be to try different images (ideally, created in different ways). That might help you determine whether it is the image that's at fault or some other factor.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Guys,

The picture viewing application uses the iamge control to display users pictures form a folder of their selection.

I have no control over what images are put into the imgcontrol1 so once a new image is chosen by a click on a button it's 'all over -red rover' if the control doesn't like it. <sigh>

William

 
William,

I have no control over what images are put into the imgcontrol1

I understand that. The point that both Imaginecorp and myself were making was that you should at least test your code with images from other sources so that you can eliminate possible image corruption as the cause of the problem.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
button71

The image control in VFP 6 supports a limited range of image types, and, FI, .tif(f) is not one of them.

You can reduce the likelihood of an error by using the JUSTEXT() function to determine that only valid image file types are selected for viewing.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommander.com
PDFcommander.co.uk
 
Thanks Mike and Chris,

My code is working perfectly with many users - image types are tested for etc etc.

The problem is that I have no control over the images selected by the user. Some cause the C000005 error hence I am asking can I stop the application from collapsing at that point?

Regards

Willaim
 
The problem is that I have no control over the images selected by the user. Some cause the C000005 error hence I am asking can I stop the application from collapsing at that point?

Unfortunately you cannot stop the application from collapsing.

Chris gave you the perfect solution; Check for Image types with JUSTEXT() before displaying.

Here is some code to give you an idea:

Code:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


	**************************************************
*-- Form:         form1 (\imaginecorp\imageform.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   02/15/07 12:03:00 AM
*
DEFINE CLASS form1 AS form


	Top = 11
	Left = 54
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT image1 AS image WITH ;
		Stretch = 1, ;
		Height = 150, ;
		Left = 33, ;
		Top = 30, ;
		Width = 310, ;
		Name = "Image1"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 202, ;
		Left = 80, ;
		Height = 27, ;
		Width = 225, ;
		Caption = "Select an Image to View...", ;
		Name = "Command1"


	PROCEDURE command1.Click
		cImage = Getfile("BMP;GIF","Select an Image")
		If Not Inlist(Justext(cImage),"BMP","GIF")
			=Messagebox("Sorry "+Justext(cImage)+;
			" files are not supported" +CHR(13)+;
			"Please Select a 'Bmp', 'Gif' Image only",16,'Image Viewer')
			Return
		Else
			Thisform.image1.Picture = cImage
		Endif
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
 

An alternative to Imaginecorp's code in the .Click() event of his form listing the supported file types would be:-
Code:
[COLOR=blue]LOCAL lcPict
lcPict = GetPict('VFP6 supported graphic files:JPG,BMP,GIF,DIB;JPG;BMP;GIF;DIB',;
'Get Picture','Open')[/color]
The description of the list would need amending to suit the app.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommander.com
PDFcommander.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top