Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Change texbox fontname programmatically?
Message
De
14/06/2002 13:37:02
 
 
À
14/06/2002 13:21:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00668651
Message ID:
00668677
Vues:
25
Definite. I expected it to work, but it does nothing. Can you try my code on your machine? Here is my code (I saved the form as a class to get it):
oform=CREATEOBJECT('changefont')
oform.show()


DEFINE CLASS changefont AS form


	Top = 0
	Left = 0
	Height = 199
	Width = 425
	DoCreate = .T.
	Caption = "Change Textbox FontName Example"
	Name = "Form1"
	WindowType=1
	DIMENSION gafontarray[1,1]


	ADD OBJECT combo1 AS combobox WITH ;
		RowSourceType = 2, ;
		RowSource = "cafonts.cfont", ;
		ControlSource = "m.cn_preprta", ;
		Height = 24, ;
		Left = 48, ;
		Style = 2, ;
		Top = 24, ;
		Width = 228, ;
		Name = "Combo1"


	ADD OBJECT text1 AS textbox WITH ;
		Value = "This is an example of the font.", ;
		Height = 23, ;
		Left = 48, ;
		ReadOnly = .T., ;
		TabStop = .F., ;
		Top = 58, ;
		Width = 336, ;
		Name = "Text1"


	ADD OBJECT combo2 AS combobox WITH ;
		RowSourceType = 2, ;
		RowSource = "casize.csize", ;
		ControlSource = "m.cn_preprtb", ;
		Height = 24, ;
		Left = 288, ;
		Style = 2, ;
		Top = 24, ;
		Width = 60, ;
		Name = "Combo2"


	PROCEDURE load
		SET SAFETY OFF
		CREATE TABLE cafonts (cfont c(30))
		IF !USED('cafonts')
			USE cafonts IN 0
		ENDIF
		CREATE TABLE casize (csize c(2))
		IF !USED('casize')
			USE casize IN 0
		ENDIF
	ENDPROC
	
	PROCEDURE Init
		*--init
		=AFONT(thisform.gaFontArray)
		SELE cafonts
		FOR i = 1 TO ALEN(thisform.gaFontArray,1)
			APPEND BLANK
			REPLACE cafonts.cfont WITH gaFontArray(i)
		ENDFOR
		GO TOP
		SELE casize
		FOR i = 6 TO 12 STEP 2
			APPEND BLANK
			REPLACE casize.csize WITH ALLTRIM(STR(i))
		ENDFOR
		GO TOP
		LOCATE FOR casize.csize="12"
		IF EOF()
			GO TOP
		ENDIF
		m.cn_preprtb=casize.csize
		SELE cafonts
		INDEX ON cfont TAG cfont
		SET ORDER TO TAG cfont
		GO TOP
		m.cn_preprta=cafonts.cfont
		thisform.combo2.requery()
		thisform.combo2.refresh()
		thisform.text1.click()
		DODEFAULT()
	ENDPROC


	PROCEDURE combo1.Valid
		*!*	THISFORM.text1.fontname=thisform.combo1.value
		*!*	THISFORM.text1.value="This is an example of the font "+thisform.combo1.value
		*!*	THISFORM.text1.fontsize=11
		*!*	THISFORM.text1.refresh()
		DODEFAULT()
		THISFORM.text1.click()
	ENDPROC


	PROCEDURE text1.Click
		THIS.value="This is an example of the font "+thisform.combo1.value
		This.fontname=thisform.combo1.value
		thisform.refresh()
		DODEFAULT()
	ENDPROC


ENDDEFINE
Tracy
>>I've been trying to change the fontname of a textbox programmatically using the following code:
>>
>>
>>THIS.value="This is an example of the font "+thisform.combo1.value
>>This.fontname=thisform.combo1.value
>>this.refresh()
>>
>>
>>However, while the value changes as it should, the fontname does not. The textbox retains the original fontname from when the form was instantiated. Any ideas?
>
>Are you sure? I put your code in a textbox click() method and it works just as you would expect...
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform