How print multiple chart in a CScrollView

TeeChart for ActiveX, COM and ASP
Post Reply
franco
Newbie
Newbie
Posts: 1
Joined: Tue Oct 11, 2005 4:00 am
Location: Pinerolo (TO)
Contact:

How print multiple chart in a CScrollView

Post by franco » Thu Mar 09, 2006 12:18 pm

Hello, I'm going to create a application that present more charts on the same view (it's a CScrollView).
Well, I can create the chart at run time, and it's ok, but How can I do to print the ScrollView contents (all data charts) in one A3 paper sheet ?

Thanks, for any suggestions.

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Mar 15, 2006 1:07 am

Hi,

one solution could be to do a custom print on the Printer canvas using similar technique as in the below example (which prints the Chart and other custom objects like texts..) :

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

You can also see one example of this under:
C:\Program Files\Steema Software\TeeChart Pro v7 ActiveX Control\Examples\Visual Basic\Visual Basic 5 & 6\Canvas Handle

Post Reply