Bug? Call to move cursor has a minor bug.

rgarnett1955

Active Member
Licensed User
Longtime User
Hi Klaus,

If the user adds an xGraph_Touch subroutine the system crashes in xGraph line 402 due to an incorrect parameter being passed:

xGraph xpnlCursor.TOUCH_ACTION_MOVE:
        Case xpnlCursor.TOUCH_ACTION_MOVE
            If X >= Graph.Left And X <= Graph.Right And Y > Graph.Top And Y < Graph.Bottom Then
                If mCursorMode = 0 Then
                    Private TC0 As CursorsData
                    TC0 = lstTwoCursors.Get(mCurrentCursor)
                    TC0.XIndex = Max(0, (x - Graph.Left) / Graph.Width * (ScaleX.IEnd - ScaleX.IBegin) + ScaleX.IBegin + 0.5)
                    TC0.XIndex = Min(TC0.XIndex, ScaleX.NbSamples - 1)
                    DrawTwoCursors
                    If mSynchronizeGraphs = True Then
                        Private TC1 As CursorsData
                        TC1 = mGraphToSynchronize.lstTwoCursors.Get(mCurrentCursor)
                        mGraphToSynchronize.SetCursor(TC0.XIndex, mCurrentCursor, TC1.Color)
                    End If
                    If xui.SubExists(mCallBack, mEventName & "_CursorPositionChanged", 2) Then
                        CallSubDelayed3(mCallBack, mEventName & "_CursorPositionChanged", mCurrentCursor, TC0.XIndex) 'rjg mod: should it be TC0.XIndex not TC.XIndex
                    End If
                Else If CursorActive = True Then
'                    DrawItemValues(X)
                    DrawStandardCursor(X, CursColor)
'                    xcvsCursor.ClearRect(RectCursor)
'                    xcvsCursor.DrawLine(X, Graph.Top, X, Graph.Bottom - 2dip, CursColor, 2dip)
'                    RectCursor.Initialize(X - 2dip, Graph.Top, X + 2dip, Graph.Bottom)
'                    xcvsCursor.Invalidate
                End If
            Else If Zoomed = True And CursorActive = False And Y > Graph.Bottom And Y < xpnlCursor.Height And X > RectZoomCursor.Left And X < RectZoomCursor.Right Then
                ZoomDelta = X - ZoomX
                If ZoomDelta < 0 Then
                    ScaleX.IBegin = Max (0, IBegin + ZoomDelta / ZoomScale)
                    ScaleX.IEnd = ScaleX.IBegin + IndexDelta
                Else
                    ScaleX.IEnd = Min(ScaleX.NbSamples - 1, IEnd + ZoomDelta / ZoomScale)
                    ScaleX.IBegin = ScaleX.IEnd - IndexDelta
                End If

                If xui.SubExists(mCallBack, mEventName & "_ZoomChanged", 2) Then
                    CallSubDelayed3(mCallBack, mEventName & "_ZoomChanged", ScaleX.IBegin, ScaleX.IEnd)
                End If

                DrawZoomCursor
                DrawGraph
            End If
    End Select

I put in TC0.XIndex, which works OK, but I'm not sure if this will work for other cases. i.e when synchronized with another graph.

Best regards
Rob
 
Top