Board index » delphi » Aligning text with Canvas
Rafn Yngvi Rafnsson
![]() Delphi Developer |
Sun, 28 Feb 1999 03:00:00 GMT
|
Rafn Yngvi Rafnsson
![]() Delphi Developer |
Sun, 28 Feb 1999 03:00:00 GMT
Aligning text with CanvasHi everybody. |
Brien Ki
![]() Delphi Developer |
Sun, 28 Feb 1999 03:00:00 GMT
Re:Aligning text with CanvasOn Wed, 11 Sep 1996 13:24:03 +0200, Rafn Yngvi Rafnsson Quote>Hi everybody. Canvas.Font.Sytle := [fsBold]; Canvas.TextOut(X,Y,'My Text Goes Here'); Brien King |
Martin Larsso
![]() Delphi Developer |
Sun, 28 Feb 1999 03:00:00 GMT
Re:Aligning text with CanvasQuoteRafn Yngvi Rafnsson wrote: M. -- |
Jochen Heyla
![]() Delphi Developer |
Mon, 01 Mar 1999 03:00:00 GMT
Re:Aligning text with CanvasIn article <3236A153.4...@post3.tele.dk>, r...@post3.tele.dk says... Quote>Hi everybody. I've found A way - just not sure it's the best one. You can use the handle of the canvas to access the basic Windows functions. In this case, you can use ExtTextOut, passing it a rectangle in which to justify. First you need to call SetTextAlign to set the alignment option. I've had some problems with old printers that would not align correctly, so I actually wound up using GetTextExtent to get the length of the string and changing the y parameter to start at the right edge minus the width of the text minus 1. Anyone have a better way ? Hope this helps, Jochen |
Stephen Pet
![]() Delphi Developer |
Fri, 05 Mar 1999 03:00:00 GMT
Re:Aligning text with CanvasIn article <3236A153.4...@post3.tele.dk>, Quote>Hi everybody. Have a look at the extracts below: {-------------------------------------------------------------------------} Quote} procedure output_text (canvas : Tcanvas; x,y, just : integer; s : string); {-------------------------------------------------------------------------} begin canvas.pen.color := colour; if printing then case just of CentreTop : x := x - canvas.TextWidth(s) div 2; RightTop : x := x - canvas.TextWidth(s); canvas.TextOut(x,y, s); cheers _--_|\ Stephen Peter School of Architecture |
Giuseppe Mos
![]() Delphi Developer |
Sat, 06 Mar 1999 03:00:00 GMT
Re:Aligning text with CanvasRafn Yngvi Rafnsson <r...@post3.tele.dk> wrote: Quote>Hi everybody. ------------------------ procedure TForm1.FormCreate(Sender: TObject); var S:String; begin S:='CIAO!'; with Image1.Canvas do TextOut(ClipRect.Right-TextWidth(S)-1,ClipRect.Top+2,S); end; --------------------- TextOut and TextWidth are fields of TCanvas. Ciao. Giuseppe Mosca Via Nilo,20 65016 Montesilvano (PE) Italy Giuseppe Mosca Via Nilo, 20 65016 Montesilvano (PE) |