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 6063867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:12:59+00:00 2026-05-23T09:12:59+00:00

code sample procedure TForm1.Button1Click(Sender: TObject); var r: Trect; s: String; begin R := Rect(0,0,

  • 0

code sample

procedure TForm1.Button1Click(Sender: TObject);
var
  r: Trect;
  s: String;
begin
  R := Rect(0,0, 300, 100);
  s := 'WordWrapTextOut(TargetCanvas: TCanvas; var x, y: integer; S: string; maxwidth, lineheight: integer);';
  DrawText(Canvas.Handle, PChar(s),  length(s), R, DT_WORDBREAK or DT_LEFT);
end;

I want to wrap the text in 300px width but how can I get the new Height? Is there a way or any solution?

  • 1 1 Answer
  • 0 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-23T09:13:00+00:00Added an answer on May 23, 2026 at 9:13 am

    If you want to update your rectangle before drawing the text you could use DT_CALCRECT. DrawText will then modify your rectangle to the new height (and width if necessary). If you only need the height though use the return value as Andreas Rejbrand showed.

    Here’s a sample of this:

    procedure TForm1.Button1Click(Sender: TObject);
    var
      r: Trect;
      s: String;
    begin
      R := Rect(0,0, 300, 100);
      s := 'WordWrapTextOut(TargetCanvas: TCanvas; var x, y: integer; S: string; maxwidth, lineheight: integer);';
      if DrawText(Canvas.Handle, PChar(s),  length(s), R, DT_CALCRECT or DT_WORDBREAK or DT_LEFT) <> 0 then
      begin
        DrawText(Canvas.Handle, PChar(s),  length(s), R, DT_WORDBREAK or DT_LEFT);
        r.Top := r.Bottom;
        r.Bottom := r.Bottom * 2;
        DrawText(Canvas.Handle, PChar(s),  length(s), R, DT_WORDBREAK or DT_LEFT);
      end;
    end;
    

    I would recommend reading the docs for more details:
    http://msdn.microsoft.com/en-us/library/dd162498(v=vs.85).aspx

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

Sidebar

Related Questions

Take the following code as a sample: procedure TForm1.Button1Click(Sender: TObject); var Obj: TSomeObject; begin
I have some simple code: procedure TForm1.Button1Click(Sender:TObject); var x: RawByteString; begin x := UTF8Encode('testing
I have used the following code to create the XML Document : procedure TForm1.btnCreateXMLClick(Sender:
My current code is : DELIMITER \\ CREATE PROCEDURE sample (IN _car VARCHAR(15)) BEGIN
Here is my sample code. It is meant to be an iterative procedure for
Here I provide simple piece of code. function GetStringList:TStringList; var i:integer; begin Result:=TStringList.Create; Result.Add('Adam');
Delphi 1 16-bit (yeah it's old, but it works well) Some sample code: procedure
I Have created a procedure which has code like this: Create PROCEDURE Sample( @ID
I use DBMS_STATS.GATHER_SCHEMA_STATS procedure to collect statistics in my code. BEGIN DBMS_STATS.gather_schema_stats (ownname =>
So, simple procedure, calculate a factorial number. Code is as follows. int calcFactorial(int num)

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.