Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Loading Images Procedure
Message
From
29/04/2017 11:13:44
 
 
To
29/04/2017 10:48:50
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01650671
Message ID:
01650677
Views:
46
>Does your Image control, in the profile form, has a fixed filename? If it can be changed, where does your application store the filename?
>
>Answer: I have not thought about those two questions, at this point. However, they are valid. I prefer to allow the system to re-name the files to a system generated name. That way each customer will not name the files any name they want which could cause problems later on. Keeping all the format names the same.

Please wear a helmet, because this is just coded and not tried, nor ran. Even if it does not fully work, hopefully it will give any ideas to work on. It is meant to be a subclass of the Image control, and adapted to a visual class so that you can easily incorporate in a form. Finally, it was adjusted to VFP6 and (at least) successfully compiled.
#DEFINE SAFETHIS	!USED("This") AND VARTYPE(This) == "O"

DEFINE CLASS LogoImage AS Image

	Storage = "C:\MyApp\Images"
	ValidWidth = 205
	ValidHeight = 133
	Proportional = .T.
	UniqueFileName = .T.

	FUNCTION Upload

		SAFETHIS

		LOCAL OriginalImageFile
		LOCAL TemporaryImageFile
		LOCAL FinalImageFile
		LOCAL TemporaryImage
		
		This.Picture = ""

		m.OriginalImageFile = GETPICT()
		IF !EMPTY(m.OriginalImageFile)
			m.TemporaryImageFile = ADDBS(SYS(2023)) + SYS(2015) + "." + JUSTEXT(m.OriginalImageFile)
			COPY FILE (m.OriginalImageFile) TO (m.TemporaryImageFile)  
			m.TemporaryImage = CREATEOBJECT("image")
			m.TemporaryImage.Picture = m.TemporaryImageFile
			DOEVENTS
			IF (m.TemporaryImage.Width = This.ValidWidth AND m.TemporaryImage.Height = This.ValidHeight) OR ;
					(This.Proportional AND ;
						(ROUND(m.TemporaryImage.Width / This.ValidWidth, 0) = ROUND(m.TemporaryImage.Height / This.ValidHeight, 0)))
				IF This.UniqueFileName
					m.FinalImageFile = ADDBS(This.Storage) + SYS(2015) + "." + JUSTEXT(m.OriginalImageFile)
				ELSE
					m.FinalImageFile = This.Storage
				ENDIF
				COPY FILE (m.TemporaryImageFile) TO (m.FinalImageFile)
				This.Picture = m.FinalImageFile
			ENDIF
		ENDIF
		
		RETURN !EMPTY(This.Picture)
	ENDFUNC

ENDDEFINE
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform