Page 1 of 1

Using TAnnotationTool at runtime

Posted: Mon Jun 21, 2021 9:13 pm
by 16591021
I am trying to create/delete TAnnotationTool at runtime so I can show text messages base on user choice.

I am able to create them at run time, but I am running in to few issues.

1- I can create them and add them to the tools list of the TChart object, but I am unable to delete them. I always get an invalid pointer error.

Is possible to create/delete the annotation at runtime?

Re: Using TAnnotationTool at runtime

Posted: Thu Jun 24, 2021 10:58 am
by yeray
Hello,

This seems to work fine for me without problems:

Code: Select all

uses TeeTools;

procedure TForm1.Button1Click(Sender: TObject);
begin
  TAnnotationTool(Chart1.Tools.Add(TAnnotationTool)).Text:='Annotation';
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if (Chart1.Tools.Count>0) and (Chart1.Tools[0] is TAnnotationTool) then
  begin
    Chart1.Tools.Delete(0);
    Chart1.Draw;
  end;
end;