Change Font undefined SAY

Change Font undefined SAY

Postby Marcelo Via Giglio » Thu May 07, 2015 2:38 am

hello to all,

are there some way to change the say's font of the undefined SAY, I mean if we define says in dialog (resource) is possible to change the font of the SAY without redefine it?

regards

Marcelo
Marcelo Via Giglio
 
Posts: 1051
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: Change Font undefined SAY

Postby ukoenig » Thu May 07, 2015 10:20 am

Marcelo,

at the end of the defined dialog ( or window ) add :

Code: Select all  Expand view

AEVAL( oDlg:aControls, ;
     { | oCtl | IIF( oCtl:ClassName() == "TSAY", ;    // only SAY is used
                       ( oCtl:SetFont( oFont1  ), ;   // change font
                         oCtl:Setcolor( 255,  ), ;    // change to red
                         oCtl:Refresh() ), NIL ) } )
 


best regards
Uwe :)
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Change Font undefined SAY

Postby Marcelo Via Giglio » Thu May 07, 2015 11:37 am

Thanks,

I want to change the font of the says no redefined from a dialog, I think your solution is for says explicitly defined

Thanks and regards

Marcelo
Marcelo Via Giglio
 
Posts: 1051
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: Change Font undefined SAY

Postby Rick Lipkin » Thu May 07, 2015 1:40 pm

Marcelo

I hope this is what you are looking for ?

Rick Lipkin

Code: Select all  Expand view

#Include "FiveWin.Ch"

//---------------------
Func Main()

Local oFontA,oFontB,oSay,cSay,oBtn1

oFontB  := TFont():New("Ms Sans Serif",,-6,.F.,.T. ,,,,.F. )
oFontA  := TFont():New("New Times Roman",,-10,.F.,.T. ,,,,.F. )
cSay     := "Testing Boiler Plate Text"

LightGreyGrad() // creates gradient and the transparent flag for dialog

DEFINE DIALOG oDlg SIZE 300, 300

   @ 1, 1 Say oSay PROMPT cSay OF oDlg
          oSay:SetFont( oFontB )
          oSay:SetColor(nRgb(7,7,224)) // blue

   @ 3,1 BUTTON "Change Font" of oDlg SIZE 40,12 ;
          ACTION ( oSay:SetFont(oFontA),oSay:SetColor(CLR_HRED),oSay:ReFresh() )

ACTIVATE DIALOG oDlg CENTERED

RELEASE FONT oFontB
RELEASE FONT oFontA

Return(nil)


//------------------
Func LightGreyGrad()

SetDlgGradient( { { .50, nRGB( 216, 216, 216 ), nRGB( 255, 255, 255 ) } } )

Return(nil)

 
User avatar
Rick Lipkin
 
Posts: 2634
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Change Font undefined SAY

Postby Gale FORd » Thu May 07, 2015 1:59 pm

I think he want to change the fonts of the text controls with an ID of -1 in the resource.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Change Font undefined SAY

Postby Rick Lipkin » Thu May 07, 2015 2:03 pm

Gale

You are correct .. control ID -1 can not be changed .. you have to create a Text Control with a valid ID in your .rc and then REDEFINE with Color and Font with Code.

Rick Lipkin

Code: Select all  Expand view

LTEXT "Vendor Id", 112, 8, 39, 60, 12, SS_NOPREFIX | WS_GROUP
 


Code: Select all  Expand view

REDEFINE SAY oSay27 Id 112 OF oDlg UPDATE
oSay27:SetFont( oFontB )
oSay27:SetColor( nRgb( 7,7,224 ))
 
User avatar
Rick Lipkin
 
Posts: 2634
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Change Font undefined SAY

Postby Carlos Mora » Thu May 07, 2015 2:45 pm

Hi Marcelo,

you want to change the font of an undefined control, so wou'll have "to get your hands dirty".

First, get the handle (hWnd) of every child control in your dialog, then check the id (-1) and type (Static) of that control to identify your target(s), and then change the font. Sth like

Code: Select all  Expand view

   // oDlg your Dialog and oFont the font to set to
   hCtrl := GetWindow( oDlg:hWnd, GW_CHILD )
   WHILE hCtrl != 0
      IF GetClassName( hCtrl ) == "Static" .AND. GetWindowLong( hCtrl, GWL_ID ) == -1
         SendMessage(  hCtrl, WM_SETFONT, oFont:hFont )
      ENDIF
      hCtrl := GetWindow( hCtrl, GW_HWNDNEXT )
   ENDDO
 


Warning: I haven't tryed it, so it is not under warranty :) I think it should work.
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: Change Font undefined SAY

Postby Marcelo Via Giglio » Fri May 08, 2015 1:43 am

Thanks to all for the responses

Carlos thanks your suggestion, this work very well, now

are there the possibility to change the color too?

best regards

Marcelo
Marcelo Via Giglio
 
Posts: 1051
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: Change Font undefined SAY

Postby Carlos Mora » Fri May 08, 2015 1:10 pm

Marcelo,

You can get the fish, or learn how to fish ;)
The matter is: using a control's (windows) handle, change it's color (like ::SetColor() does). One of the blessings of using FW is that you have 99% of the source code, so we have the very basic resource for research. Take a look into TWindows source and find out by yourself, i'm pretty sure you can! Show me that i'm not wrong :)

Best regards
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: Change Font undefined SAY

Postby Marcelo Via Giglio » Fri May 08, 2015 10:33 pm

Carlos,

good philosophy, if I find the solution, I will publish it here

Thanks

Marcelo
Marcelo Via Giglio
 
Posts: 1051
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: Change Font undefined SAY

Postby Rick Lipkin » Sat May 09, 2015 1:38 pm

Marcelo

Several years ago I was faced with a similar situation .. look for a workaround for Static text ID -1 or just go through each .rc and assign and replace each -1 with an ID number of your choice.

When you have a unique ID for your text, it makes it so much easier to code fonts,color and transparency.
Code: Select all  Expand view

from .rc
LTEXT "Vendor Id", 112, 8, 39, 60, 12, SS_NOPREFIX | WS_GROUP
 

Code: Select all  Expand view

REDEFINE SAY oSay27 Id 112 OF oDlg UPDATE
oSay27:SetFont( oFontB )
oSay27:SetColor( nRgb( 7,7,224 ))
 


Just my 2 cents worth.
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2634
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests