Page 1 of 1

How can I show multiple asTeeCursors

Posted: Thu Aug 04, 2005 7:35 pm
by 9080335
I am currently using v7.0 ActiveX TChart control and am trying to display more that one cursor at a time (actually up to 5 cursors). One of the cursors needs to follow the mouse, while the other cursors need to be static based on a selected location (selected by using Shift Click). I have added code in the Form_Load event to create 5 Cursors; I have also added code to the TChart_OnMouseDown event to capture the Shift status and set the 2nd-5th cursor style to visible and.FollowMouse = false (if previously Pen.Style set to clear) . I am unable to lock the position of the any cursor and make them visible; the only cursor that is visible is the 1st cursor, which continues to trace the mouse movement.

I have used the sample Axes.vbp project as the basis and added the necessary code in the above events. I am including the modified events below. Am I missing something,or is this not possible? Any assistance would be very appreciated.

Code: Select all

Private Sub Form_Load()
Dim i
  With TChart1
    For i = 0 To 20
     .Series(0).Add Rnd(30), "", clTeeColor
     .Series(1).Add Rnd(30), "", clTeeColor
    Next i
  End With
      ' Add 2 cursors
    TChart1.Tools.Add tcCursor
    With TChart1.Tools.Items(0).asTeeCursor
        .FollowMouse = True
        .Style = cssVertical
        .Pen.Color = vbBlue
        .Pen.Style = psSolid
        .Pen.Width = 3
    End With
  For i = 0 To 3
    TChart1.Tools.Add tcCursor
    With TChart1.Tools.Items(TChart1.Tools.Count - 1).asTeeCursor
        .FollowMouse = False
        .Style = cssVertical
        .Pen.Color = vbGreen
        .Pen.Style = psClear
        .Pen.Width = 3
        
    End With
  Next i
  
  ExistsCustomAxis = False
End Sub
Private Sub TChart1_OnMouseDown(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)

    'MsgBox TChart1.Tools.Count
    If Shift = ssShift Then
        With TChart1.Tools.Items(0).asTeeCursor
            .Series = 0
            .FollowMouse = True
            .Style = cssVertical
            .Pen.Color = vbRed
            .Pen.Style = psSolid
            .Pen.Width = 2
           '// .XVal = X
        End With
        For i = 1 To 4
            With TChart1.Tools.Items(i).asTeeCursor
                If .Pen.Style = psClear Then
                    .Series = 0
                    .FollowMouse = False
                    .Style = cssVertical
                    .Pen.Color = vbGreen
                    .Pen.Style = psDash
                    .Pen.Width = 5
                    .XVal = X
                    Exit For
                End If
            End With
        Next i
        'MsgBox "Setup cursor Processed"
    End If
    
   ' MsgBox X & ", " & Y


End Sub

Thanks for your help

Scott

Posted: Fri Aug 05, 2005 1:56 pm
by Pep
Hi Scott,

you must change the following line :
XVal = X
by this one :
.XVal = TChart1.Series(0).XScreenToValue(X)