Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1046673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:11:00+00:00 2026-05-16T16:11:00+00:00

Consider the following code: procedure TForm1.PaintBox1Paint(Sender: TObject); var vRect : TRect; vFormat : TTextFormat;

  • 0

Consider the following code:

procedure TForm1.PaintBox1Paint(Sender: TObject);
var
  vRect : TRect;
  vFormat : TTextFormat;
  vStr : string;
begin
  vStr := 'This is some text';
  vRect := rect(10,10,50,130);
  vFormat := [tfCenter,tfVerticalCenter,tfWordBreak];
  PaintBox1.Canvas.Rectangle(vRect);
  PaintBox1.Canvas.TextRect(vRect,vStr,vFormat);
end;

I would expect something like this

+--------+
|        |
|        |
|This is |
|  some  |
|  text  |
|        |
|        |
+--------+

but I get this

+--------+
|This is |
|  some  |
|  text  |
|        |
|        |
|        |
|        |
+--------+

The same is true for the tfBottom format. The horizontal text formats (tfLeft, tfRight, tfCenter) work as expected, but the vertical formats doesn’t. Can anyone explain this?

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:11:01+00:00Added an answer on May 16, 2026 at 4:11 pm

    I’m not pretty sure but VerticalCenter is only allowed if singleline is set.
    This is because Canvas relies on native windows functions. If you look at Windows DrawText function you will see this restriction.
    If you need to vertical center you have to do your own maths

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider following code for an android app; private String GetDistance(String src, String dest) {
Consider the following psuedo T-SQL code (performed by a stored procedure): CREATE TABLE #localTable
Consider following code: ArrayList<Integer> aList = new ArrayList<Integer>(); aList.add(2134); aList.add(3423); aList.add(4234); aList.add(343); String tmpString
Please consider the following code: type TFoo1 = class public procedure DoSomething1; end; TFoo2
Consider following code public class City { public string Name { get { return
Consider the following code, public class StartUp { public StartUp(String[] test){} public static void
Consider following code: Dim S1 As String = a 'this is the string in
Consider the following code: SqlConnection conn = new SqlConnection(@connection string); SqlCommand ourCommand = new
Consider following code: My problem is: 1) I can't seem to cast the errors
Consider following code: enum size = 16; double[size] arr1 = [...]; double[size] arr2 =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.