IPrinter.PrintPartialHandle
IPrinter
procedure PrintPartialHandle(DC: OleVariant; Left, Top, Right, Bottom: Integer);
Type Library
TeeChartx
Description
Use PrintPartialHandle to 'attach' a TeeChart to an existing print job. This permits the mixture of TChart[s] with other non-chart, printer page output. Take care to change the TeeChart Printer Orientation to reflect that of the current print job.
Example [Visual Basic]:
Private Sub Command1_Click()
Dim HWidth, HHeight, ChartLeft, ChartTop, ChartRight, ChartBottom ' Declare variables.
On Error GoTo ErrorHandler ' Set up error handler.
Printer.Orientation = vbPRORPortrait
'Scale & position text.
HWidth = Printer.TextWidth(Text1.Text) / 2 ' Get half width.
HHeight = Printer.TextHeight(Text1.Text) / 2 ' Get half height.
Printer.CurrentX = Printer.ScaleWidth / 3 - HWidth
Printer.CurrentY = Printer.ScaleHeight / 3 - HHeight
Printer.Print Text1.Text ' Print 1st Text box
With TChart1.Printer
'Chart needs to orientated separately
.Orientation = poPortrait
'Set the chart position
ChartLeft = .PageWidth / 3
ChartTop = (.PageHeight / 3) + 30
ChartRight = (.PageWidth / 3) * 2
ChartBottom = (2 * (.PageHeight / 3)) - HHeight - 10
'Attach the Chart output to the open print job
.PrintPartialHandle Printer.hDC, ChartLeft, _
ChartTop, ChartRight, ChartBottom
End With
Printer.CurrentY = 2 * Printer.ScaleHeight / 3 - HHeight
Printer.CurrentX = Printer.ScaleWidth / 3 - HWidth
Printer.Print Text2.Text ' Print 2nd Text box
Printer.EndDoc ' Printing is finished.
Exit Sub
ErrorHandler:
MsgBox "There was a problem printing to your printer."
Exit Sub
End Sub