procedure TBasicForm.BitBtn1Click(Sender: TObject);
Var tmpH,tmpW,tmpWMargin,tmpHMargin:Longint; { margins }
OldOrientation:TPrinterOrientation;
begin
Screen.Cursor := crHourGlass;
OldOrientation:=Printer.Orientation; { <-- save paper orientation }
Printer.Orientation:=poLandscape; { <-- Force Horizontal paper }
try
Printer.BeginDoc; { <-- start printer job }
try
Printer.Title:='TeeChart Printing Demo';
Case RadioGroup1.ItemIndex of
0: Begin { screen proportional }
Chart1.PrintResolution:= 0;
Chart2.PrintResolution:= 0;
Chart3.PrintResolution:= 0;
Chart4.PrintResolution:= 0;
End;
1: Begin { thin lines and small fonts }
Chart1.PrintResolution:= -100;
Chart2.PrintResolution:= -100;
Chart3.PrintResolution:= -100;
Chart4.PrintResolution:= -100;
End;
end;
{ Print the four charts, each one at a different paper position }
{ CALCULATE HORIZONTAL MARGIN }
tmpW:=Printer.PageWidth;
tmpWMargin:=Round(5.0*tmpW/100.0); { <-- 5% margins }
tmpW:=tmpW-2*tmpWMargin; { <-- left and right margins }
tmpW:=tmpW div 2; { half height for left and right charts }
{ CALCULATE VERTICAL MARGIN }
tmpH:=Printer.PageHeight;
tmpHMargin:=Round(5.0*tmpH/100.0); { <-- 5% margins }
tmpH:=tmpH-2*tmpHMargin; { <-- bottom and top margins }
tmpH:=tmpH div 2; { half height for top and bottom charts }
{ left / top chart }
Chart1.PrintPartial( Rect( tmpWMargin,tmpHMargin,
tmpWMargin+tmpW,tmpHMargin+tmpH ) );
{ right / top chart }
Chart3.PrintPartial( Rect( tmpWMargin+tmpW,tmpHMargin,
tmpWMargin+2*tmpW,tmpHMargin+tmpH ) );
Printer.EndDoc; { <-- end job and print !! }
except
on Exception do { just in case an error happens... }
Begin
Printer.Abort;
Printer.EndDoc;
Raise;
end;
end;
finally
Printer.Orientation:=OldOrientation; { <-- restore paper orientation }
Screen.Cursor:=crDefault; { <-- restore cursor }
end;
end;