How to Set TITLETEXT Center of TTITLE?

Post Reply
User avatar
dutch
Posts: 1612
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

How to Set TITLETEXT Center of TTITLE?

Post by dutch »

Dear All,

I use TTITLE and TITLETEXT, TITLETEXT prompt is dynamic word.
How can I set TITLETEXT as Center of TTITLE?

Thanks in advance for any idea or suggestion.

Regards,
Dutch

FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
karinha
Posts: 8720
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: How to Set TITLETEXT Center of TTITLE?

Post by karinha »

Good afternoon Dutch, please post a simple example for testing. It will be easier to help that way.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
Posts: 8720
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: How to Set TITLETEXT Center of TTITLE?

Post by karinha »

Dutch, in this short example, what are you missing? Please show me what you would like to do but don't have.

Dutch, en este breve ejemplo, ¿qué te falta? Por favor, muéstrame qué te gustaría hacer pero no tienes.

Code: Select all | Expand

// C:\FWH2603\SAMPLES\TITTEST1.PRG - [email protected]

#include "FiveWin.ch"
#include "constant.ch"
#include "ttitle.ch"

STATIC oWnd

FUNCTION Main()

   LOCAL aGradBox := { nRgb( 255,255,255), nRgb(254,254,254)}
   LOCAL oTitle, oTitle1, oTitle3, oldTitle, oFontTitle, oBrush, oBox, oSay, ;
         oBtn, oBoldTitle

   DEFINE BRUSH oBrush GRADIENT aGradBox

   DEFINE FONT oBoldTitle NAME 'Tahoma' SIZE 0, -16  BOLD
   DEFINE FONT oFontTitle NAME 'Tahoma' SIZE 0, -18

   DEFINE WINDOW oWnd TITLE "Exemplo de TTitle" COLOR "N/W*"

   // Criando o Title
   @ 0, 0 TITLE oTitle OF oWnd SIZE oWnd:nWidth, 40 // BRUSH oBrush // no me gusta.

   // Adicionando Gradiente ao Title  -> +-
   // oTitle:aGrdBack := { { 1, nRgb( 255,255,255), nRgb(254,254,254) } }

   // good
   oTitle:aGrdBack := { { 0.5, nRGB( 100, 100, 100 ), nRGB( 0, 0, 0 ) }, ;
                        { 0.5, nRGB( 0, 0, 0 ), nRGB( 100, 100, 100 ) } }

   // Sombra/vulto/fantasma. jajajaja.
   // oTitle:nShadow  := 0  // good. 

   // Adicionando Texto ao Title
   @ 10, 20 SAY "Relatório de Vendas" OF oTitle COLOR "W+" PIXEL  UPDATE     ;
      FONT oFontTitle

   @ 40, 0 TITLE oTitle OF oWnd SIZE oWnd:nWidth, 40 // NOBORDER //PIXEL

   oTitle:aGrdBack := { { 1, nRgb( 255,255,255), nRgb(254,254,254) } }
   // oTitle:nShadow  := 0

   @ 05, 15 TITLETEXT OF oTitle TEXT "Text1" COLOR "+R+W+" FONT oBoldTitle 3d

   @ 14, 20 TITLEIMG OF oTitle BITMAP "..\bitmaps\16X16\close.bmp" TRANSPARENT ;
     SIZE 30, 16 REFLEX ANIMA ACTION MsgInfo( "fire any action from here" )

   oTitle:lRound    := .T.
   oTitle:lBorder   := .T.
   oTitle:nClrLine1 := 255

   @ 90, 00 TITLE oTitle1 SIZE oWnd:nWidth, 50 OF oWnd // BRUSH oBrush // no good

   oTitle1:aGrdBack = {}
   oTitle1:nShadow := 0
   oTitle1:lTransparent := .T.
   // oTitle1:Show()

@ 010, 20 SAY oSay  PROMPT "Relatório de Vendas" OF oTitle1 COLOR "W+" ;
   PIXEL FONT oFontTitle CENTER SIZE 500, 18 UPDATE

// Object oSay
oSay:SetText("             New Centered Text             " )

   @ 180, 210 BTNBMP oBtn PROMPT "&Exit" SIZE 100, 30 OF oWnd ;
      ACTION( oWnd:End() ) CENTER

   oBtn:cToolTip := "Exit"

   ACTIVATE WINDOW oWnd CENTERED

   oBrush:End()
   oBoldTitle:End()
   oFontTitle:End()

RETURN NIL

// FIN / END
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
Posts: 8720
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: How to Set TITLETEXT Center of TTITLE?

Post by karinha »

More,

Code: Select all | Expand

   // @ 05, 15 TITLETEXT OF oTitle TEXT "Text1" COLOR "+R+W+" FONT oBoldTitle 3d

   @ 05, 12 TITLETEXT OF oTitle COLOR CLR_WHITE ;
      TEXT +SPACE(30) + "Centered Title Text"   ;
      FONT oBoldTitle 3d

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
Posts: 8720
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: How to Set TITLETEXT Center of TTITLE?

Post by karinha »

Master Antonio, why doesn't it work this way? The CENTER command causes an error.

Code: Select all | Expand

   // Example based on FiveWin forum discussions
   DEFINE WINDOW oWnd TITLE "Centered Title"

   // Define a title object with center alignment
   @ 0, 0 TITLE oTitle OF oWnd SIZE 100, 30 TEXT "Centered Title" CENTER

   @ 05, 12 TITLETEXT OF oTitle COLOR CLR_WHITE ;
      TEXT "Centered Title Text"                ;
      FONT oBoldTitle 3d CENTER // ERROR

   ACTIVATE WINDOW oWnd

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
Antonio Linares
Site Admin
Posts: 44515
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: How to Set TITLETEXT Center of TTITLE?

Post by Antonio Linares »

Dear Joao,

@ ... TITLETEXT command has no CENTER clause (ttitle.ch:63).
Preprocessor leaves CENTER token unmatched → compile error. Only clauses: TEXT/CAPTION/TITLE, JUSTIFY, BRUSH, PEN,
SHADOW, FONT, COLOR, 3D/RELIEVE. To center: drop CENTER, compute nCol = (titleWidth - textWidth)/2 manually.

Want me to add a real CENTER clause to TITLETEXT + AddText?

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
dutch
Posts: 1612
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How to Set TITLETEXT Center of TTITLE?

Post by dutch »

Dear Antonio&Karinha,

Yes, I think CENTER is useful clause. Because I made program to support Multi Language to support user define text. I cannot use 1 coordination to support user define.

Thanks,

Antonio Linares wrote: Sun May 17, 2026 11:01 am

Dear Joao,

@ ... TITLETEXT command has no CENTER clause (ttitle.ch:63).
Preprocessor leaves CENTER token unmatched → compile error. Only clauses: TEXT/CAPTION/TITLE, JUSTIFY, BRUSH, PEN,
SHADOW, FONT, COLOR, 3D/RELIEVE. To center: drop CENTER, compute nCol = (titleWidth - textWidth)/2 manually.

Want me to add a real CENTER clause to TITLETEXT + AddText?

Regards,
Dutch

FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
Antonio Linares
Site Admin
Posts: 44515
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: How to Set TITLETEXT Center of TTITLE?

Post by Antonio Linares »

Dear Dutch,

Already added for next FWH build :idea:

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
karinha
Posts: 8720
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: How to Set TITLETEXT Center of TTITLE?

Post by karinha »

Antonio Linares wrote: Mon May 18, 2026 3:59 am

Dear Dutch,

Already added for next FWH build :idea:

Excellent, dear master. Please let me know when the new build for version 26.03 beta is ready for me to test.

Gracias, tks.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
Posts: 8720
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: How to Set TITLETEXT Center of TTITLE?

Post by karinha »

Code: Select all | Expand

// c:\fwh2603\samples\TITTEST2.PRG - simples example.

#Include "FiveWin.ch"
#Include "ttitle.ch"

FUNCTION Main()

   LOCAL oWnd, oTitle, oFont
   
DEFINE FONT oFont NAME "Tahoma" SIZE 0, -14 BOLD DEFINE WINDOW oWnd TITLE "FiveWin TTitle Center Example" // Define the TTITLE bar @ 0, 0 TITLE oTitle OF oWnd SIZE oWnd:nWidth, 50 // @ 10, 20 TITLETEXT oTextRef OF oTitle TEXT "Your Centered Text" ; // FONT oFont COLOR CLR_BLACK CENTER // Define the TITLETEXT centered @ 15, 100 TITLETEXT OF oTitle TEXT "This Text Is Centered" FONT oFont CENTER ACTIVATE WINDOW oWnd oFont:End() RETURN NIL // FIN / END

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Post Reply