Page 1 of 1

Title does not appear on the printed page (TeePreviewPanel)

Posted: Thu Nov 24, 2005 3:20 pm
by 9525700
Cannot find a previous reference to this.

Essentially
I have a TeePreviewPanel named tppPrint

I add 2 charts to this

tppPrint.addChart chart1
tppPrint.addChart chart2

The title is set on the OnAfterDraw event as follows
With tppPrint.Canvas
.TextOut x, y, "title"
End With

Also tried the
tppPrint.Title = "Title"
But this has no effect

This appears fine on the Preview Panel but when the object is printed it loses the title.

Posted: Thu Nov 24, 2005 3:22 pm
by 9525700
Version 7.0.0.4

Posted: Fri Nov 25, 2005 12:12 pm
by narcis
Hi dineena,

To print elements that are not into the chart area you should use something like the code below:

Code: Select all

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
 

Private Sub Form_Load()
Text1.Text = "This first text box should be placed on top of the TeeChart Object."
With TChart1
    .AddSeries scLine
    .Series(0).FillSampleValues 100
End With
Text2.Text = "This second text box should be placed below the TeeChart Object."
End Sub