Print Problem

TeeChart for ActiveX, COM and ASP
Post Reply
DH
Newbie
Newbie
Posts: 7
Joined: Wed Sep 24, 2003 4:00 am
Location: Germany
Contact:

Print Problem

Post by DH » Thu Jul 22, 2004 12:03 pm

Hello,

I'm new to this newsgroup and have a simple question. I'm using Teechart Pro 6.0

I want to print a whole graph including the panel with its backcolor but when I use the ShowPreview-Method the background everytime has a white color.

Could anybody please tell me, how I can manage to print with the correct background color.

Thanks in advance.
Dirk

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

Post by Pep » Thu Jul 22, 2004 4:31 pm

Hi Dirk,

yes, this cannot be done with the actual version, it's on our wish list as as feature request to be considered for future releases. In meantime, a workaround could be to use the following code :

Code: Select all

Dim Printing As Boolean

Private Sub Command1_Click()
Printing = True
TChart1.Repaint
TChart1.Printer.PrintChart
Printing = False
TChart1.Repaint
End Sub

Private Sub Form_Load()
Printing = False
With TChart1
    .AddSeries scLine
    .Series(0).FillSampleValues 10
    .Axis.Bottom.Labels.Font.Color = vbWhite
    .Axis.Left.Labels.Font.Color = vbWhite
    .Frame.Color = vbWhite
    .Axis.Bottom.GridPen.Visible = False
    .Axis.Left.GridPen.Visible = False
End With
End Sub

Private Sub TChart1_OnBeforeDrawChart()
If Printing = True Then
    Dim MyLeft, MyTop, MyRight, MyBottom As Double
    With TChart1
        .Canvas.Brush.Color = vbBlack
        MyLeft = .Canvas.Left - .Axis.Left.Position
        MyTop = .Canvas.Top - .Axis.Top.Position
        MyBottom = .Canvas.Height - .Axis.Bottom.Position
        MyRight = .Canvas.Width - .Axis.Right.Position
        .Canvas.Rectangle .Axis.Left.Position + MyLeft, .Axis.Top.Position + MyTop, .Axis.Right.Position - MyRight, .Axis.Bottom.Position - MyBottom
    End With
Else
    With TChart1
        .Canvas.Brush.Color = vbBlack
        .Canvas.Rectangle .Canvas.Left, .Canvas.Top, .Canvas.Width, .Canvas.Height
    End With
End If
End Sub

DH
Newbie
Newbie
Posts: 7
Joined: Wed Sep 24, 2003 4:00 am
Location: Germany
Contact:

Post by DH » Tue Jul 27, 2004 8:15 am

Hi,

first of all thanks for your fast answer.

I solved the problem in another way. I changed the gradient startcolor, midcolor and endcolor to the panel color and then the background was printed in the correct way.

Post Reply