Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculating widths and heights of strings
Message
De
28/11/2005 09:23:53
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01072336
Message ID:
01072424
Vues:
20
Below is a method that I wrote to determine the maximum string length based on a width. It uses a form standard method, so it must be a method of a form.
LPARAMETERS pcTextString,pnLabelWidth
LOCAL lnNdx, lcDrive, lcTest, lnStart
lnStart = ATC(":\",pcTextString)
IF lnStart > 0
*-*	Trim path
	lnStart = lnStart + 1
	lnNdx   = 0
	lcTest  = pcTextString
	lcDrive = LEFT(pcTextString,lnStart) + ".."
	DO WHILE thisform.TextWidth(pcTextString) > pnLabelWidth
		lnNdx = lnNdx + 1
		DO WHILE SUBSTR(pcTextString,lnStart+lnNdx,1) != "\" .AND. lnStart+lnNdx <= LEN(pcTextString)
			lnNdx = lnNdx + 1
		ENDDO
		IF SUBSTR(pcTextString,lnStart+lnNdx,1) != "\"
			pcTextString = lcTest
			EXIT
		ENDIF
		lcTest = lcDrive + SUBSTR(pcTextString,lnStart+lnNdx)
		IF thisform.TextWidth(lcTest) <= pnLabelWidth
			pcTextString = lcTest
			EXIT
		ENDIF
	ENDDO
ELSE
*-*	Trim text description
	pcTextString = pcTextString
ENDIF
RETURN pcTextString
You can possibly adopt this to determine how wide you need for the form.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform