Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pixels and Foxels conversion
Message
From
16/03/2003 21:19:18
Peter Easson
Catalina Trading
Sydney, Australia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00766384
Message ID:
00766409
Views:
39
Here is one extra little tweak. I found that it still could be inaccurate as the Form that had focus could be different from _SCREEN in the calculation
*-* Conversion
FUNCTION Foxel2Pixel(oForm,tlnFoxelValue, tllVertical)

	RETURN ROUND(tlnFoxelValue / GetPixFoxRatio(oForm,tllVertical), 0)

ENDFUNC


FUNCTION Pixel2Foxel(oForm,tlnPixelValue, tllVertical)

	RETURN ROUND(tlnPixelValue * GetPixFoxRatio(oForm,tllVertical), 3)

ENDFUNC


FUNCTION GetPixFoxRatio(oForm,tllVertical)

	LOCAL lnSaveScaleMode, lnFoxel, lnPixel, ;
 		  lnRatio

	*----------------------------------------------------
	*-- Get all required values for our calculations
	*----------------------------------------------------

	WITH oForm

		*-- Save old ScaleMode of the form
		lnSaveScaleMode = .ScaleMode

		.ScaleMode = 0 &&SCALEMODE_FOXELS	

		IF tllVertical
			lnFoxel = .Height
		ELSE
			lnFoxel	= .Width
		ENDIF

		.ScaleMode = 3 && SCALEMODE_PIXELS

		IF tllVertical
			lnPixel = .Height
		ELSE
			lnPixel	= .Width
		ENDIF

		*-- Calculate Foxel to Pixel factors
		lnRatio = lnFoxel / lnPixel

		*-- Set ScaleMode back
		.ScaleMode = lnSaveScaleMode

	ENDWITH

	RETURN lnRatio

ENDFUNC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform