0
votes

Below code gives me access violation. Can anyone help me with this.

for(long i = nTools-1; i > 0 ; i--)
{
    if(m_spGraph.GetTools().GetItems(i).GetToolType() == 25 && m_spGraph.GetTools().GetItems(i).GetAsRectangle().GetAllowDrag() == TRUE)  // Rectangle tool
    {
        m_spGraph.GetTools().Delete(i);
    }
}

Thanks Akshay

1

1 Answers

1
votes

In VB6, if I run this and then I open an Editor I see 5 Rectangle tools and 5 Annotation tools:

  TChart1.AddSeries scBar
  TChart1.Series(0).FillSampleValues 8

  Dim i As Integer
  For i = 0 To 9
    If (i Mod 2 = 0) Then
      TChart1.Tools.Add tcRectangle
    Else
      TChart1.Tools.Add tcAnnotate
    End If
  Next i

Then, If I run this and I open the editor again after it, I only see the 5 Annotation tools:

  For i = TChart1.Tools.Count - 1 To 0 Step -1
    If (TChart1.Tools.Items(i).ToolType = 25 And TChart1.Tools.Items(i).asRectangle.AllowDrag) Then
      TChart1.Tools.Delete i
    End If
  Next i

So it seems to work fine for me here.
Have you tried it with different TeeChart ActiveX builds? Have you obtained different results with each them?

Please, edit your question adding an SSCCE so we can reproduce the problem here and try to figure if there's a problem in your code or in the component.