Page 1 of 1

Move annotation

Posted: Mon Mar 02, 2009 7:43 pm
by 15046186
Is there a way to move annotations with the mouse? May be trapping some events ?? I read the post of
03 Mar 2004 (asAnnotation custom position) but I cannot get the attachment.

Thanks in advance,
Paolo Saudin

Posted: Tue Mar 03, 2009 8:29 am
by yeray
Hi spol,

Here you have a fast example of how you could do this:

Code: Select all

Dim MoveAnnotation As Boolean

Private Sub Form_Load()
  TChart1.Tools.Add tcAnnotate
  TChart1.Tools.Items(0).asAnnotation.Text = "My annotation tool"
End Sub

Private Sub TChart1_OnMouseDown(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
  If TChart1.Tools.Items(0).asAnnotation.Clicked(X, Y) Then
    MoveAnnotation = True
  End If
End Sub

Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
  If MoveAnnotation Then
    TChart1.Tools.Items(0).asAnnotation.Left = X
    TChart1.Tools.Items(0).asAnnotation.Top = Y
  End If
End Sub

Private Sub TChart1_OnMouseUp(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
  MoveAnnotation = False
End Sub

Posted: Tue Mar 03, 2009 12:09 pm
by 15046186
Thank you very much !! :D
Is what I needed