Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Canvas auto centre names Posted by Development on 11 Feb 2006 at 2:38 PM
I been trying to auto centre the names in my box around name because not all names are not the same size can anyone help me fix this so it centres all names?


    PaintInfo.Canvas.Pen.Color:= clAqua;
    PaintInfo.Canvas.Rectangle(n+20,0,n+20+PaintInfo.Canvas.TextWidth(s)+119,
    PaintInfo.Canvas.TextHeight(IMData.Name)+2);
    PaintInfo.Canvas.Font.Color := clAqua; // Account Color
    PaintInfo.Canvas.Draw(n, t, ResForm.repc.Picture.Bitmap);
    n := n + 15; // Account Icon
    PaintInfo.Canvas.TextOut(n+45,1,IMData.Name); // Screen Name



cheers and thank you

Slewis
Report
Re: Canvas auto centre names Posted by zibadian on 11 Feb 2006 at 2:43 PM
: I been trying to auto centre the names in my box around name because not all names are not the same size can anyone help me fix this so it centres all names?
:
:
: 
:     PaintInfo.Canvas.Pen.Color:= clAqua;
:     PaintInfo.Canvas.Rectangle(n+20,0,n+20+PaintInfo.Canvas.TextWidth(s)+119,
:     PaintInfo.Canvas.TextHeight(IMData.Name)+2);
:     PaintInfo.Canvas.Font.Color := clAqua; // Account Color
:     PaintInfo.Canvas.Draw(n, t, ResForm.repc.Picture.Bitmap);
:     n := n + 15; // Account Icon
:     PaintInfo.Canvas.TextOut(n+45,1,IMData.Name); // Screen Name
: 
: 

:
: cheers and thank you
:
: Slewis
:
The calculation for centering something is quite simple:
  x := (CanvasWidth - TextWidth) div 2;

where CanvasWidth is the width of the area in which the text appears, and TextWidth is the width of the text; both in pixels. X forms the left hand coordinate of the text.
Report
Re: Canvas auto centre names Posted by Development on 11 Feb 2006 at 3:17 PM
: : I been trying to auto centre the names in my box around name because not all names are not the same size can anyone help me fix this so it centres all names?
: :
: :
: : 
: :     PaintInfo.Canvas.Pen.Color:= clAqua;
: :     PaintInfo.Canvas.Rectangle(n+20,0,n+20+PaintInfo.Canvas.TextWidth(s)+119,
: :     PaintInfo.Canvas.TextHeight(IMData.Name)+2);
: :     PaintInfo.Canvas.Font.Color := clAqua; // Account Color
: :     PaintInfo.Canvas.Draw(n, t, ResForm.repc.Picture.Bitmap);
: :     n := n + 15; // Account Icon
: :     PaintInfo.Canvas.TextOut(n+45,1,IMData.Name); // Screen Name
: : 
: : 

: :
: : cheers and thank you
: :
: : Slewis
: :
: The calculation for centering something is quite simple:
:
:   x := (CanvasWidth - TextWidth) div 2;
: 

: where CanvasWidth is the width of the area in which the text appears, and TextWidth is the width of the text; both in pixels. X forms the left hand coordinate of the text.
:
hi zib would it be possable for you to redo my code for me ?
Slewis




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.