Page 1 of 1

cursor disapears with GDI+

Posted: Wed Sep 07, 2011 8:02 am
by 16659767
Hello,
In my TChart bar-graph I want to show the cursor, both by following the mouse and programatically (not at the same time).

The first option, following the mouse worked fine.
The second option, by changing ..asTeeCursor.XVal didn't work, the cursor was invisible!

After a long search I discovered that switching off GDI+ solved the problem:
I checked your examples and I noticed the same problem here,
see: TeeChartv2010FeatureDemo.exe -->All Features,Tools-Cursor-Moving programatically
With the GDI+ checkbox unchecked the cursor is visible, when checked the cursor disapears.
I already upgraded to the latest version (TeeChart2011.0.0.4ActiveX) but the effect is the same.

Because I want the graphs and the fonts to look fine I am using the GDI+ mode, is there another work around?

Best Regards,
Stef Dekker

Re: cursor disapears with GDI+

Posted: Wed Sep 07, 2011 11:10 am
by yeray
Hello Stef,

This is a known bug already in the defect list with number [TV52013842].
In the meanwhile I'm afraid the only solution is to draw an horizontal and a vertical line manually. Here is how you could do it:

Code: Select all

Dim XVal, YVal As Double
Dim Follow As Boolean

Private Sub Form_Load()  
  TChart1.Aspect.GDIPlus.Active = True
  TChart1.Aspect.View3D = False
  TChart1.Legend.Visible = False

  TChart1.AddSeries scPoint
  With TChart1.Series(0)
    .FillSampleValues
    With .asPoint
    .Pointer.HorizontalSize = 2
    .Pointer.VerticalSize = 2
    End With
  
    XVal = .XValues.Count / 2
    YVal = .YValues.Minimum + (.YValues.Maximum - .YValues.Minimum) / 2
  End With
  
  Follow = False
End Sub

Private Sub LeftButton_Click()
  XVal = XVal - 1
  TChart1.Repaint
End Sub

Private Sub RightButton_Click()
  XVal = XVal + 1
  TChart1.Repaint
End Sub

Private Sub TopButton_Click()
  YVal = YVal + SomeValue
  TChart1.Repaint
End Sub

Private Sub BottomButton_Click()
  YVal = YVal - SomeValue
  TChart1.Repaint
End Sub

Private Sub CBFollow_Click()
  Follow = CBFollow.Value
End Sub

Private Sub TChart1_OnAfterDraw()
  Dim tmpXPos, tmpYPos As Integer
  
  With TChart1.Axis
    tmpXPos = .Bottom.CalcXPosValue(XVal)
    tmpYPos = .Left.CalcYPosValue(YVal)

    If ((tmpYPos < .Left.IEndPos) And (tmpYPos > .Left.IStartPos)) Then
      TChart1.Canvas.Line .Bottom.IStartPos, tmpYPos, .Bottom.IEndPos, tmpYPos
    End If
    
    If ((tmpXPos < .Bottom.IEndPos) And (tmpXPos > .Bottom.IStartPos)) Then
      TChart1.Canvas.Line .Bottom.CalcXPosValue(XVal), .Left.IStartPos, tmpXPos, TChart1.Axis.Left.IEndPos
    End If
  End With
End Sub

Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
  If Follow Then
    XVal = TChart1.Axis.Bottom.CalcPosPoint(X)
    YVal = TChart1.Axis.Left.CalcPosPoint(Y)
    TChart1.Repaint
  End If
End Sub

Function SomeValue() As Double
  With TChart1.Series(0).YValues
    SomeValue = (.Maximum - .Minimum) / 10
  End With
End Function