TrendLine Crush
Posted: Wed Apr 14, 2004 5:56 am
Hi
if in code of my previous post "TrendLines Issues" the command button event handler replace with code below it crushes the app and sometimes Windows.
nefis
the changed part
if in code of my previous post "TrendLines Issues" the command button event handler replace with code below it crushes the app and sometimes Windows.
nefis
Code: Select all
Private Sub Command1_Click()
Dim lt As TeeChart.IDrawLineTool
Dim L As Long
Dim L2 As Long
If Xd = 0 Then
Xd = TChart1.Axis.Bottom.Maximum - TChart1.Axis.Bottom.Minimum
End If
If Yd = 0 Then
Yd = TChart1.Axis.Left.Maximum - TChart1.Axis.Left.Minimum
End If
Set lt = TChart1.Tools.Items(TChart1.Tools.Add(tcDrawLine)).asDrawLine
With lt
L = .AddLine(0, 0, 1, 1)
lt.Lines.Items(L).StartPos.X = TChart1.Axis.Bottom.Minimum + Rnd * Xd
lt.Lines.Items(L).StartPos.Y = TChart1.Axis.Right.Minimum + Rnd * Yd
lt.Lines.Items(L).EndPos.X = TChart1.Axis.Bottom.Minimum + Rnd * Xd
lt.Lines.Items(L).EndPos.Y = TChart1.Axis.Right.Minimum + Rnd * Yd
L2 = .AddLine(0, 0, 1, 1)
lt.Lines.Items(L2).StartPos.X = lt.Lines.Items(L).EndPos.X
lt.Lines.Items(L2).StartPos.Y = lt.Lines.Items(L).EndPos.Y
lt.Lines.Items(L2).EndPos.X = lt.Lines.Items(L).EndPos.X + 1000 * (lt.Lines.Items(L).EndPos.X - lt.Lines.Items(L).StartPos.X)
lt.Lines.Items(L2).EndPos.Y = lt.Lines.Items(L).EndPos.Y + 1000 * (lt.Lines.Items(L).EndPos.Y - lt.Lines.Items(L).StartPos.Y)
lt.EnableDraw = False
End With
Call TChart1.Repaint
End Sub
Code: Select all
lt.Lines.Items(L2).EndPos.X = lt.Lines.Items(L).EndPos.X + 1000 * (lt.Lines.Items(L).EndPos.X - lt.Lines.Items(L).StartPos.X)
lt.Lines.Items(L2).EndPos.Y = lt.Lines.Items(L).EndPos.Y + 1000 * (lt.Lines.Items(L).EndPos.Y - lt.Lines.Items(L).StartPos.Y)