FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to Set TITLETEXT Center of TTITLE?
Posts: 1600
Joined: Fri Oct 07, 2005 05:56 PM

How to Set TITLETEXT Center of TTITLE?

Posted: Wed May 13, 2026 01:12 PM

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)
Posts: 8559
Joined: Tue Dec 20, 2005 07:36 PM

Re: How to Set TITLETEXT Center of TTITLE?

Posted: Wed May 13, 2026 03:47 PM

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
Posts: 8559
Joined: Tue Dec 20, 2005 07:36 PM

Re: How to Set TITLETEXT Center of TTITLE?

Posted: Wed May 13, 2026 06:28 PM

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.

// C:\FWH2603\SAMPLES\TITTEST1.PRG - kapiabafwh@gmail.com

#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
Posts: 8559
Joined: Tue Dec 20, 2005 07:36 PM

Re: How to Set TITLETEXT Center of TTITLE?

Posted: Fri May 15, 2026 03:41 PM

More,

   // @ 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
Posts: 8559
Joined: Tue Dec 20, 2005 07:36 PM

Re: How to Set TITLETEXT Center of TTITLE?

Posted: Fri May 15, 2026 03:48 PM

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

   // 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
Posts: 44229
Joined: Thu Oct 06, 2005 05:47 PM

Re: How to Set TITLETEXT Center of TTITLE?

Posted: 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, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1600
Joined: Fri Oct 07, 2005 05:56 PM

Re: How to Set TITLETEXT Center of TTITLE?

Posted: Mon May 18, 2026 01:41 AM

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:

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)
Posts: 44229
Joined: Thu Oct 06, 2005 05:47 PM

Re: How to Set TITLETEXT Center of TTITLE?

Posted: Mon May 18, 2026 03:59 AM

Dear Dutch,

Already added for next FWH build :idea:

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 8559
Joined: Tue Dec 20, 2005 07:36 PM

Re: How to Set TITLETEXT Center of TTITLE?

Posted: Mon May 18, 2026 03:02 PM
Antonio Linares wrote:

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
Posts: 8559
Joined: Tue Dec 20, 2005 07:36 PM

Re: How to Set TITLETEXT Center of TTITLE?

Posted: Mon May 18, 2026 03:10 PM
// 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

Continue the discussion