Changing font from oSay

Changing font from oSay

Postby Frank Demont » Fri Aug 18, 2006 12:41 pm

Hello ,

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  Expand view  RUN
# 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
Frank Demont
 
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Postby manuramos » Fri Aug 18, 2006 4:24 pm

Try this: oSay:SetFont( oNewFont )
After changing font do: oSay:SetTex( oSay:cCaption ) to check the change. It would be OK.
Nos Gusta Programar
manuramos
 
Posts: 219
Joined: Mon Dec 26, 2005 7:25 pm
Location: Jerez de la Frontera (Spain)

Postby Frank Demont » Sat Aug 19, 2006 10:31 am

Manuramos,

Thank you very much , this i needed to complete to make windows resizing the controls , also with the font.

You may see the result in the thread from silvio (controls ...)

Frank
Frank Demont
 
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 49 guests