PrintPreview - variable TextHeight

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

PrintPreview - variable TextHeight

Postby thhz » June 24th, 2010, 7:30 pm


I'm new here and I use PrintPreview for the first time.
My question is, how can I calculate the height (and the width) of a given text at runtime?
I want to use PrintPreview for printing reports based on a database.
The printing text has sometimes 1 line, then 2 or more lines

This text has one line.
This text has line 1
and line 2
and so on

How can I calculate the different heights (to draw the DOT lines)?
printpreview1.TextHeight doesn't work.

I hope you uderstand what I mean.
I searched here in the forum but I found no solution for this problem.

Many thanks in advance

Posts: 1
Joined: June 24th, 2010, 7:18 pm

Re: PrintPreview - variable TextHeight

Postby Kambiz » June 30th, 2010, 4:29 pm

Using TextWidth and TextHeight methods of Canvas is the only way that you can get this information using Delphi VCL.

To get more precise size, you should use DrawText API of Windows.
User avatar
Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 2 guests