TECH TIP: Calculation Dynamic Height of Detail Band
Sometimes you need to know the stretched height of a dynamically sized detail band after it has printer to perform further logic. This can be done by keeping track of where the report engine currently is on the page and where it was right before that. For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
uses ppTypes, ppUtils; ... private FPos: Integer; ... procedure TForm1.ppReport1StartPage(Sender: TObject); begin FPos := 0; // reset position to 0 at beginning of every page end; ... procedure TForm1.ppDetailBand1AfterPrint(Sender: TObject); var lMMTHeight: Integer; lInchHeight: Single; begin // calculate the difference between current position and last position lMMTHeight := ppReport1.Engine.PrintPosRect.Top - FPos; // the height is in thousands of millimiters so we must convert to inches lHeight := ppFromMMThousandths(llMMTHeight, utInches, pprtVertical, nil); // save the current position FPos := ppReport1.Engine.PrintPosRect.Top; end; |