I have a form for selection of fore/backcolor, fontsize and fontname. Everything works fine, except the fontname - i.e. it GPFs in .exe, otherwise it works fine from VFP.
Af first I used a combo, then tried with a listbox, to no avail. At first (while I had the combo), it worked fine except that it GPFd when I clicked the combo's arrow or pressed alt+DnArrow; now it crashes right on. While I had the combo, at least the rest of the controls worked fine.
I'd prefer not to use the GetFont() function, because it lists some properties I don't want the user to touch, because they won't be reflected in the calling screen (bold, italic and underline are under my control, and script is shown but VFP doesn't use it in forms and reports).
Here's the relevant part:
**************************************************
*-- Form: setfont (c:\vfp\prc\setfont.scx)
*-- ParentClass: form
*-- BaseClass: form
*
DEFINE CLASS setfont AS form
ScaleMode = 0
ShowWindow = 2
DoCreate = .T.
AutoCenter = .T.
Caption = "Screen settings"
WindowType = 1
AlwaysOnTop = .T.
RightToLeft = .F.
BackColor = RGB(128,0,255)
whocalled = .NULL.
Name = "SETFONT"
DIMENSION fonts_l[1]
[snipped other objects]
ADD OBJECT tlbox1 AS tlbox WITH ;
RowSourceType = 5, ;
Height = 5.60, ;
Left = 28.80, ;
TabIndex = 2, ;
Top = 0.00, ;
Width = 40.80, ;
Name = "Tlbox1"
PROCEDURE ref_all
Local i
if !isnull(this.WhoCalled)
this.whocalled.resize
else
for each oForm in _vfp.forms
if this.name#oForm.name
oForm.resize
endif
endf
endif
ENDPROC
PROCEDURE Resize
with ThisForm
.setall("fontname",thisform.fonts_l[ThisForm.Tlbox1.value])
* .setall("fontname",ThisForm.Tlbox1.value)
.setall("fontsize",g_fontsize)
.backcolor=g_backcolor
.forecolor=g_forecolor
.setall("forecolor",g_forecolor,"label")
endwith
dodefault()
ENDPROC
PROCEDURE Init
Lpara toForm
if type("toForm")="O"
if type("toForm.name")="C"
this.whocalled=toForm
endif
endif
wait " this.backcolor" wind
this.backcolor=g_backcolor
wait " call this.resize" wind
ThisForm.Tlbox1.RowSource="thisform.fonts_l"
ENDPROC
PROCEDURE Load
Local dum[1]
=afont(dum)
dime this.fonts_l(alen(dum))
* thought this line was the culprit, but it's the same
* =afont(this.fonts_l)
* set step on
n=0
for each fo in dum
if atc("ding",fo)=0 and atc("symbol",fo)=0
n=n+1
this.fonts_l[n]=fo
endif
endfor
dime this.fonts_l(n)
ENDPROC
PROCEDURE tlbox1.Init
this.value=ascan(thisform.fonts_l,g_fontname)
if this.value=0
this.value=ascan(thisform.fonts_l,_screen.fontname)
endif
if this.value=0
this.value=1
endif
ENDPROC
PROCEDURE tlbox1.Valid
ThisForm.setall("fontname",thisform.fonts_l[This.value])
ENDPROC
PROCEDURE tlbox1.InteractiveChange
ThisForm.setall("fontname",thisform.fonts_l[This.value])
ENDPROC
ENDDEFINE
*
*-- EndDefine: setfont
**************************************************