Contents
- Index
- Previous
- Next
PrintAt method
Applies to
TProfGrid component
Declaration
function PrintAt(var ARect: TRect; ShrinkToRect, ExpandToRect: Boolean): Boolean;
Description
Instructs the grid to print itself at some specific rectangle inside a page.
The ARect parameter is a rectangle on the print page where the grid should be placed. Setting the ARect.Left and ARect.Top before calling the method is mandatory, and setting the ARect.Right and ARect.Bottom is optional, i.e. ARect.Right and ARect.Bottom may be set to some invalid values (like 0 or -1). Setting ARect.Right and ARect.Bottom to some valid values is necessary if you need to instruct the grid to print itself exactly within the specified rectangle. If ARect.Right or ARect.Bottom contains an invalid value, the page width or page height is assumed to be the right or bottom edge of the rectangle.
On return, the method fills the ARect parameter with the actual coordinates of the rectangle used for printing. Thus the resulting ARect can be handled by the calling application at will.
The ShrinkToRect and ExpandToRect parameters specify whether the grid must shrink to fit the specified rectangle, expand to fit the specified rectangle, or try both shrinking and expanding to fit the specified rectangle.
Example
The following example prints the grid at the bottom-right quarter of a page, trying both shrinking and expanding to fit in the print area:
procedure TForm1.Button1Click(Sender: TObject);
var
R: TRect;
begin
Printer.BeginDoc;
R.Left := Printer.PageWidth div 2;
R.Top := Printer.PageHeight div 2;
R.Right := -1;
R.Bottom := -1;
ProfGrid1.PrintAt(R, True, True);
Printer.EndDoc;
ShowMessage( 'The grid is printed at (' + IntToStr(R.Left) + ','
+ IntToStr(R.Top) + ',' + IntToStr(R.Right) + ','
+ IntToStr(R.Bottom) + ')' );
end;