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

Problem with PrintHeight like phDinamic

edited February 2002 in General
Hi,
My name is Fernando and I'm software develope in Brazil.
I'm working with Report Builder 6.03 professional with Delphi 5.0, and I'm
having the following problem:

At band "Detail" I have a field with values and I need that the total of
this field be printed at the end of each report. I used a component
TppDBCalc to sum the field at band Footer.
worked ! The component TppDBCalc summed correctly each value of the sheet.
My problem is when I need to set the band Detail to PrintHeight like
phDinamic. The component TppDBCalc sum the values of the sheet plus the
velue of the first register of the follow sheet.

How can I solve this problem, Please ?

Please send a e-mail to fernando@qi.inf.br.

Comments

  • edited February 2002
    Here's some code that will fix the problem.

    uses
    ppUtils, ppTypes;

    procedure Tfrm0081.ppReport1DetailBeforePrint(Sender: TObject);
    var
    llCurrentPosition: Longint;
    liLineHeight: Integer;
    llLineHeight: Longint;
    lBitmap: TBitmap;
    llPageHeight: Longint;
    llSpaceAvailable: Longint;
    llBottomOffset: Longint;
    lDetailBand: TppDetailBand;
    begin

    lDetailBand := TppDetailBand(ppReport1.GetBand(btDetail, 0));

    if (lDetailBand.BottomOffset <> 0) then
    begin
    lDetailBand.BottomOffset := 0;

    Exit;
    end;

    {get the height of a single memo line in screen pixels}
    lBitmap := TBitmap.Create;
    lBitmap.Canvas.Font := ppReport1DBMemo1.Font;
    liLineHeight := lBitmap.Canvas.TextHeight('0');
    lBitmap.Free;

    {convert the line height from screen pixels to thousandths of mm}
    llLineHeight := Round(ppFromScreenPixels(liLineHeight,
    utMMThousandths, pprtVertical, nil));

    {get the page height}
    llPageHeight := ppReport1.Engine.PageBottom;

    {get the current print position}
    llCurrentPosition := ppReport1.Engine.PrintPosRect.Bottom;

    {calculate the remaining space available}
    llSpaceAvailable := llPageHeight - llCurrentPosition;

    {if the space available is less than the line height, force the Detail
    to the next page}
    if (llSpaceAvailable <= llLineHeight) then
    begin
    {convert the line height to report units}
    llBottomOffset := Round(ppFromMMThousandths(llLineHeight + 1,
    ppReport1.Units, pprtVertical, nil));

    {assign the line height as the bottom offset}
    lDetailBand.BottomOffset := llBottomOffset;
    end;

    end;

    -
    --
    Tom Ollar
    Digital Metaphors Corporation
This discussion has been closed.