I try to change the font from a existing osay , but it seems not easy
1) obj:oFont := oFont (changed) ; obj:refresh() doesn't work
2) Obj:end()
obj := TSay():New(0,10,{||txt},oDlg,,ofont(new)... )
// from ppo-file
obj:Activate()
Seems to work , at least the first time , not when the button is clicked again (and the first font must be restored)
Is there a better solution ?
Code: Select all
# include "fivewin.ch"
//# define TEST1
FUNC MAIN
LOCAL oFont[2] , oSay , oBut[2]
LOCAL tel := 1
DEFINE FONT oFont[1] NAME "MS Sans Serif" SIZE 0, -20
DEFINE FONT oFont[2] NAME "MS Sans Serif" SIZE 0, -40
DEFINE DIALOG oDlg ;
FROM 0,0 TO 200,400 PIXEL
@ 0,10 SAY oSay VAR "TEST FONT 1" OF oDlg PIXEL FONT ofont[1]
@ 40,20 BUTTON oBut[1] PROMPT "Change font oSay" OF oDlg ACTION (ChangFont(oSay , ofont , @tel)) PIXEL SIZE 80,20 FONT ofont[1]
@ 65,90 BUTTON oBut[2] PROMPT "CANCEL" OF oDlg ACTION (oDlg:end()) PIXEL SIZE 80 , 30 FONT oFont[2]
ACTIVATE DIALOG oDlg CENTER
RETURN lOk
PROC ChangFont(Obj,aofont,tel)
*******************************
LOCAL txt := "Changed " + LTRIM(STR(tel))
LOCAL nWidth := Obj:nWidth , nHeight := Obj:nHeight
LOCAL n , f
# ifdef TEST1
Obj:oFont := aofont[2]
Obj:Varput(Txt)
Obj:refresh() // Font is not changed
RETURN
# else
IF tel%2 == 1
n := 2
f := 2
ELSE
n := 1
f := 1/2
ENDIF
Obj:end()
obj := TSay():New(0,10,{||txt},oDlg,,aofont[n],.F.,.F.,.F.,.T.,,,nWidth*f,nHeight*f,.F.,.F.,.F.,.F.,.F. )
obj:Activate()
obj:refresh()
tel++
RETURN
# endif