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

TppMemo sizes

edited June 2004 in General
Subject - TppMemo sizes

I am using a TppMemo component.
I am restricted to a fixed memo size. (So I can't make it stretch)

How do I know the number of rows in the memo and the
number of characters across (assuming a non proportional
font)?

I am using property Lines to fill the memo.
I guess I need to somehow take into account the Font,
Leading, Height and Width?

I have checked the news server tech-tips with no success.

Regards, Peter Evans

Comments

  • edited June 2004
    Hi Peter,

    My suggestion would be to convert all measurement into Thousandths of
    Millimeters (microns) and procede from there. To find out the actual
    measurements of the memo, use the TppMemo.mmWidth, and mmHeight properties.
    Then, by finding out the aproximate width of a single character in the font
    you are using (say a capital "W" since it is generally the longest), you can
    calculate about how many characters can fit on one line, then based on the
    font height, calculate the height of your memo.

    uses
    ppUtils,
    ppTypes;

    function TForm1.FindTextWidth(aText: String; aFont: TFont): Integer;
    var
    lBitmap: TBitmap;
    liSPWidth: Integer;
    begin

    lBitmap := TBitmap.Create;

    try
    lBitmap.Canvas.Font := aFont;
    liSPWidth := lBitmap.Canvas.TextWidth(aText);

    Result := ppUtils.ppToMMThousandths(liSPWidth, utScreenPixels,
    pprtHorizontal, nil);

    finally
    lBitMap.Free;
    end;

    end;

    --
    Thanks for supporting ReportBuilder! Please vote for ReportBuilder in the
    Delphi Informant Readers Choice awards!

    http://www.delphizine.com/ballot2004/

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2004
    Thank you, I have now been able to get my routine working.
    Regards, Peter
This discussion has been closed.