Board index » delphi » Centered Text

Centered Text


2004-04-24 02:33:19 AM
delphi202
Hi
Is there a simple way to Do a " TextOut" call but have the string of text
Centered about the "X,Y" coordinate ? is there a flag I need to set?
Thanks
Gary
 
 

Re:Centered Text

Quote
Is there a simple way to Do a " TextOut" call but have the string of text
Centered about the "X,Y" coordinate ? is there a flag I need to set?
Use DrawText(.., DT_CENTER)
or
TextOut((Height-TextHeight('Ag') div 2, (Width-TextWidth('Ag')), 'Ag')
Alex
 

Re:Centered Text

Prior to TextOut(),
SetTextAlign( Canvas.Handle, TA_CENTER ); -- see WinAPI help for more
information ...
"Gary" <XXXX@XXXXX.COM>writes
Quote
Hi
Is there a simple way to Do a " TextOut" call but have the string of text
Centered about the "X,Y" coordinate ? is there a flag I need to set?

Thanks
Gary


 

Re:Centered Text

You can use drawtext to calculate the bounding rectangle and then move that
rectangle in he place you wand and call drawtext again to actually draw the
text on your canvas
"Gary" <XXXX@XXXXX.COM>writes
Quote
Hi
Is there a simple way to Do a " TextOut" call but have the string of text
Centered about the "X,Y" coordinate ? is there a flag I need to set?

Thanks
Gary