Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Customize text box font size and Font Name?
Message
From
09/01/2020 02:22:31
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01672514
Message ID:
01672557
Views:
124
Likes (1)
>Hi,
>
>Do you allow your users/customers to change/customize the font size and/or font name of the textboxes?
>
>I am considering adding the feature, of allowing the user to change/customize these properties. But not sure if this is a good practice.

I do that, in one case. There's this object:
* dcfonts.prg
Define Class FontS As Custom

	Procedure Getfont(o)
		If Pcount()=0
			Aevents(a,0)
			o=a[1]
		Endif

		cFont=Getfont(o.FontName,o.FontSize,Iif(o.FontBold,"B","")+;
			Iif(o.FontItalic, "I",""), o.fontcharset)
		If !Empty(cFont)
			This.setprop(o,"FontName",Getwordnum(cFont,1,","))
			This.setprop(o,"FontSize",Val(Getwordnum(cFont,2,",")))
			This.setprop(o,"FontBold","B"$Getwordnum(cFont,3,","))
			This.setprop(o,"FontItalic","I"$Getwordnum(cFont,3,","))
			this.setprop(o, "fontCharSet", val(Getwordnum(cFont,4,",")))
		Endif
	Procedure setprop(oObj, cProp, cValue)
		If Getpem(oObj, cProp)#cValue
			AddProperty(oObj, cProp, cValue)
		Endif

	Procedure Save(o)
		Local o,c
		c=Sys(1272,o)
		This.Write(c,o, "fontname")
		This.Write(c,o, "fontsize")
		This.Write(c,o, "fontbold")
		This.Write(c,o, "fontitalic")
		This.Write(c,o, "fontCharSet")

	Procedure Write(cSect, o, cProperty)
		If Pemstatus(o, cProperty,5)
			If Pemstatus(o, cProperty,0)
				prof_w(cSect, cProperty, Getpem(o, cProperty))
			Endif
		Endif

	Procedure Bind
		Lparameters o
		If Pemstatus(o, "fontname",5)
			If Pemstatus(o, "rightclick",5)
				Bindevent(o, "rightclick",This, "getfont")
			Endif
		Endif

	Procedure Load(o)
		Local o,c
		c=Sys(1272,o)
		This.Read(c, o, "fontname","C")
		This.Read(c, o, "fontsize","N")
		This.Read(c, o, "fontbold","L")
		This.Read(c, o, "fontitalic","L")
		This.Read(c, o, "fontcharset","N")

	Procedure Read(cSect, o, tcproperty, tcType)
		Local c, cValue
		*[2006/04/07 19:23:28] dragan - zajebi sekciju
		cValue=Getpem(o, tcproperty)
		c=prof_r(o, tcproperty, cValue, tcType)
		If Not cValue=c
			AddProperty(o, tcproperty, c)
		Endif
Enddefine
Where prof_r and prof_w are wrappers to read/write profile string from the app's .ini file. This object is added to the form via
thisform.newobject("oFonts", "fonts", "dcfont.prg")
this.newobject("oRecurse","recurser","recurse.prg")
thisform.orecurse(this, "thisform.setfont")
thisform.orecurse(this, "thisform.ofonts.bind")

the code in form.setfont:
Lpara O
If Pemstatus(O, "fontsize",5)
*	If Pemstatus(O, "rightclick",5)
	IF INLIST(o.baseclass, "Textbox", "Editbox", "Header", "Label", "Commandbutton")
		With	Thisform.oFonts
			.Load(O)
			.Bind(O)
		Endwith
	Endif
Endif
The recurse.prg can be found here in downloads.

Now the main thing: the one case where I'm using this is when there is only one user. I had a customer who wanted this, so he was the user for a number of years. Then I found the app usable to myself (the editor to write autobiography), so the user is me now. You'll find that this is the best frame of programmer-client relationship for features of this kind.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform