TppDBText Adjust Font Size
Hello,
I have a TppDBText in a report line with a fixed width and nominal font
size. The datafield length will allow for occasional longer text than can
fit in the TppDBText and the text will be clipped. At runtime I would like
to determine the text length in relation to the control width and reduce the
font size to allow the text to fit the control.
I had done this same thing in a similar project many years ago. But I don't
have access to that code and have a mental block.
I would really appreciate your help.
Thanking you,
Michael Malinowski
Production Resource Group (PRG)
I have a TppDBText in a report line with a fixed width and nominal font
size. The datafield length will allow for occasional longer text than can
fit in the TppDBText and the text will be clipped. At runtime I would like
to determine the text length in relation to the control width and reduce the
font size to allow the text to fit the control.
I had done this same thing in a similar project many years ago. But I don't
have access to that code and have a mental block.
I would really appreciate your help.
Thanking you,
Michael Malinowski
Production Resource Group (PRG)
This discussion has been closed.
Comments
Inside the OnGetText event of the DBText control you will want to
measure the text (using the Canvas.TextWidth routine) and compare it to
the width of the control itself. If the text is larger than the
control, you will want to reduce the font size and perform the same test
in a loop until the text fits.
Your code will be similar to the example below only instead of adding
"..." when the text is too long, you will run your loop to test
different font sizes.
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Formatting/How_To...Format_Text_With_Ellipse
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com