Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Rich Text Control
Message
 
À
15/08/2001 09:50:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00544045
Message ID:
00544177
Vues:
22
>VFP 6.0 SP4.
>Is there a way to programmatically change the default font on a Rich Text Control box. I can force the font in the Richtext Control Properties during development, but I need to be able to switch fonts programmatically.
>Any Ideas.
>
>TIA
>Rob

If you are wanting to set all of the text within the control to one font, here is a method that I wrote that sets the font from the string that the native VFP GETFONT() function returns, i.e., "Font Name,Size,attributes" e.g. "Courier New,11,B"
PROCEDURE SetFontFromString()
LPARA tcFont

LOCAL cName, nSize, cAttrib, nPos1, nPos2
LOCAL lnPos, lnLength

WITH THISFORM.oleRichText
	IF !EMPTY(tcFont) AND OCCURS(",",tcFont) >= 2
		&& save current selection
		lnPos = .SelStart
		lnLength = .SelLength
		&& now select all text
		.SelStart = 0
		.SelLength = LEN(.TextRTF)
		nPos1 = AT(",",tcFont,1)
		nPos2 = AT(",",tcFont,2)
		cName = LEFT(tcFont,nPos1-1)
		.SelFontName = cName
		nSize = VAL( SUBSTR(tcFont, nPos1 + 1, nPos2 - nPos1) )
		.SelFontSize = nSize
		cAttrib = SUBSTR( tcFont+" ", nPos2 + 1 )
		.SelBold = IIF("B" $ cAttrib,.T.,.F.)
		.SelItalic = IIF("I" $ cAttrib,.T.,.F.)
		.SelUnderline = IIF("U" $ cAttrib,.T.,.F.)
		&& go back to previous selection
		.SelStart = lnPos
		.SelLength = lnLength
	ENDIF
ENDWITH
ENDPROC
I hope this helps,
-Lou.
"All my life I said I wanted to be someone ...
I can see now that I should have been more specific." -Jane Wagner
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform