I've done this in VB dotNet in order to print a label with long names. I shrank the font until the string fit in the space available. I suppose you can do it from delphi using windows api. There is a Measure method. If I recall correctly (a dubious proposition, at best), you create a font object, set size and content, and call Measure. I think I created a label in memory (ie, no form) and used that, perhaps so I could set its length in designer units and get back the length in units to use when measuring.
Jeremy -----Original Message----- From: advanced_delphi@yahoogroups.com on behalf of dosiemoe Sent: Wed 4/15/2009 5:25 PM To: advanced_delphi@yahoogroups.com Subject: [advanced_delphi] Calculate string length in millimeters based on other HDC Is it that impossible to calcutate how wide a given string will print, in millimeters, if I don't have the printer's canvas before-hand? So a font is actually a logical font, it will be a whole different things once we use SelectObject from one canvas to another. MSDN said there will be round off error when using logical unit other than MM_TEXT, but I found that it is ridiculously huge. At first I thought it is going to be at most one char wide. I'm going to find out more about Portable TrueType Metric, and Design Units. ------------ FIreHAzaR:-D West Java, Indonesia
<<winmail.dat>>