Page 1 of 1

Adding scrollbars to chart component VC++

Posted: Thu Jul 08, 2004 12:38 pm
by 9080443
any way to do it?

Thank you in advance.

Michael.

Posted: Thu Jul 08, 2004 5:44 pm
by Pep
Hi Michael,

yes, you can use similar code to the following. It's VB code but I think it can be easily translated to VC++-

Code: Select all

Dim AxisMin, AxisMax

Private Sub Form_Load()
HScroll1.Min = 0
HScroll1.Max = 100
HScroll1.Value = 50
With TChart1
    .Aspect.View3D = False
    .AddSeries scLine
    For i = 0 To 100
        .Series(0).AddXY i, Rnd * 100, "", clTeeColor
    Next i
    .Environment.InternalRepaint
    AxisMin = .Axis.Bottom.Minimum
    AxisMax = .Axis.Bottom.Maximum
End With
End Sub
 
Private Sub HScroll1_Scroll()
With TChart1
    If HScroll1.Value < 50 Then
        .Axis.Bottom.SetMinMax AxisMin - (50 - HScroll1.Value), AxisMax - (50 - HScroll1.Value)
    Else
        .Axis.Bottom.SetMinMax AxisMin + (HScroll1.Value - 50), AxisMax + (HScroll1.Value - 50)
    End If
End With
End Sub
 
Private Sub TChart1_OnScroll()
With TChart1
    If (.Axis.Bottom.Minimum + 50) > HScroll1.Min And (.Axis.Bottom.Maximum - 50) < HScroll1.Max Then
        HScroll1.Value = .Axis.Bottom.Minimum + 50
    End If
End With
End Sub