Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Is there a function or procedure that gives the Width of a component?

edited September 2003 in General
I'd like to be able to find out (in inches) the width of a particulat
caption

I'm using:
ppReport.Printer.Canvas.Font.Size := iPointSize;

this_liTextWidth := ppReport.Printer.Canvas.TextWidth(ppLabel.Caption);
this_liTextWidth := ppToMMThousandths(this_liTextWidth,
utPrinterPixels,pprtHorizontal, ppReport.Printer);

liDPI := ppLabel.Font.PixelsPerInch;
Result := ((this_liTextWidth / liDPI) / InchPerMM);


The result is far from close.

Thanks

Comments

  • edited September 2003
    I guess this is cheating - but it works
    this_ppLabel :=
    TppLabel.Create(ppDetailBand);
    this_ppLabel.CharWrap := False;
    this_ppLabel.WordWrap := False;
    this_ppLabel.Font := ppLabel.font;
    this_ppLabel.Width := 0;
    this_ppLabel.Autosize := True;
    this_ppLabel.Caption := ppLabel.Caption;
    this_dWidth := this_ppLabel.Width;
    this_ppLabel.Destroy;
    Result := this_dWidth;
  • edited September 2003
    Hi Joe,

    The ppToMMThousandths class function will give you the width of the label
    text in thousandths of a millimeter or microns. You can then convert to
    inches by using the constant .00003937 inches per micron (or 25400 microns
    per inch). So to get inches, you would do something like the following...

    Result := this_liTextWidth * (InchPerMM / 1000);

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.