FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Change Font undefined SAY
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Change Font undefined SAY
Posted: Thu May 07, 2015 02: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

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Change Font undefined SAY
Posted: Thu May 07, 2015 10:20 AM
Marcelo,

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

Code (fw): Select all Collapse
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.
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: Change Font undefined SAY
Posted: 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

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Change Font undefined SAY
Posted: Thu May 07, 2015 01:40 PM
Marcelo

I hope this is what you are looking for ?

Rick Lipkin

Code (fw): Select all Collapse
#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)
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Change Font undefined SAY
Posted: Thu May 07, 2015 01:59 PM

I think he want to change the fonts of the text controls with an ID of -1 in the resource.

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Change Font undefined SAY
Posted: Thu May 07, 2015 02: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 (fw): Select all Collapse
LTEXT "Vendor Id", 112, 8, 39, 60, 12, SS_NOPREFIX | WS_GROUP


Code (fw): Select all Collapse
REDEFINE SAY oSay27 Id 112 OF oDlg UPDATE
oSay27:SetFont( oFontB )
oSay27:SetColor( nRgb( 7,7,224 ))
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: Change Font undefined SAY
Posted: Thu May 07, 2015 02: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 (fw): Select all Collapse
   // 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"
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: Change Font undefined SAY
Posted: Fri May 08, 2015 01: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

Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: Change Font undefined SAY
Posted: Fri May 08, 2015 01: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"
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: Change Font undefined SAY
Posted: Fri May 08, 2015 10:33 PM

Carlos,

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

Thanks

Marcelo

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Change Font undefined SAY
Posted: Sat May 09, 2015 01: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 (fw): Select all Collapse
from .rc
LTEXT "Vendor Id", 112, 8, 39, 60, 12, SS_NOPREFIX | WS_GROUP

Code (fw): Select all Collapse
REDEFINE SAY oSay27 Id 112 OF oDlg UPDATE
oSay27:SetFont( oFontB )
oSay27:SetColor( nRgb( 7,7,224 ))


Just my 2 cents worth.
Rick Lipkin

Continue the discussion