Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Foxel vs Pixel
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00670546
Message ID:
00670590
Vues:
36
Hi,

>If the text is 12.000 foxels, what width will i have to set the text box to display the text.

here's some code for you ...

Since the ratio is different for vertical and horizonal sizes, you have to pass .T. to the conversion functions if you want a vertical size to be converted.

If you don't need the conversion for the same font (see George's reply)that's defined for _SCREEN, you might have to expand the functions to accept a font as an additional parameter as well and set that font before calculating the ratio.

HTH,
Armin
FUNCTION FoxelToPixel(tlnFoxelValue, tllVertical)

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

ENDFUNC


FUNCTION PixelToFoxel(tlnPixelValue, tllVertical)

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

ENDFUNC


FUNCTION GetPixFoxRatio(tllVertical)

	LOCAL lnSaveScaleMode, lnFoxel, lnPixel, ;
 		  lnRatio

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

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

		.ScaleMode = SCALEMODE_FOXELS	

		IF tllVertical
			lnFoxel = .Height
		ELSE
			lnFoxel	= .Width
		ENDIF
		
		.ScaleMode = 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

Armin Neudert
Regional Director (Stuttgart) of German FoxPro User Group dFPUG

MCP for Visual FoxPro

Expert/Editor of the VFP section in the German Codezone community portal
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform