I have a problem in printing a large network map (a set of points and lines). I want to print only a portion of the map. So I used SelectClipRgn to change the ClipRect property of the printpreview canvas. PrintPreview seemed to display the resulting image correctly, but printed an empty page when I clicked on the print button. Not sure what caused the problem and how to solve the problem.
Any input is highly appreciated.
Below please find my code for this:
- Code: Select all
///////////////////////////////////////////////////////////////////
procedure CreateMyPage;
var
R, R0: TRect;
MyRgn: HRGN
with PrintPreview do
begin
R:=PageBounds;
R0:=Canvas.ClipRect; {somehow, R0 is greatly different from R}
OneCM := ConvertXY(100, 100, mmLoMetric, Units);
end;
InflateRect(R, -(OneCM.X), -(OneCM.Y)); {target region}
MyRgn := CreateRectRgn(R.Left,R.top,R.Right,R.Bottom);
SelectClipRgn(PrintPreview.Canvas.Handle, MyRgn); {change ClipRect}
MapBoard.SetupPrintBoard (PrintPreview.Canvas); {pass canvas }
MapBoard.Print; {MapBoard draw map objects here}
SelectClipRgn(PrintPreview.Canvas.Handle, 0); {Restore default ClipR}
DeleteObject(MyRgn);
End;
////////////////////////////////////////////////////////////
Jack
//Mod Edit: phpBB's code tag is hard to use, eh?