Page 1 of 1

PrintPreview - variable TextHeight

PostPosted: June 24th, 2010, 7:30 pm
by thhz
Hello,

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
like

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

Thomas

Re: PrintPreview - variable TextHeight

PostPosted: June 30th, 2010, 4:29 pm
by Kambiz
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.