Page 1 of 1

Drawing on Canvas

Posted: Tue May 03, 2005 4:28 pm
by 9083304
Sorry to be a nuisance but none of my help files are helpful.

On my chart I have a vertical teecursor following mouse no problem.
If cursor is on and user left-clicks, I want to drop a stationary line at the current xval of the cursor. Is this easy to do?
I see I may be able to simply add yet another vertical cursor that doesn't follow mouse, but how do I determine tool(0) xval on a click event?

Thanks again...
Ross

Posted: Wed May 04, 2005 9:15 am
by narcis
Hi Ross,

You can draw directly to the chart canvas. The OnMouseDown event already gives you X and Y values:

Code: Select all

Private Sub TChart1_OnMouseDown(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    With TChart1
      .Canvas.MoveTo X, .Axis.Top.Position
      .Canvas.LineTo X, .Axis.Bottom.Position
    End With
End Sub
You can also determine tool's X and Y values using the OnCursorToolChange event.