creating AnnotationTool by code

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
mtspp
Newbie
Newbie
Posts: 12
Joined: Mon Oct 04, 2004 4:00 am

creating AnnotationTool by code

Post by mtspp » Wed Jun 28, 2006 4:16 pm

When I create an array of TAnnotationTools by code they do never display.
AnnotationTools created in the editor works as expected.
What am I doing wrong ?

MAXBARSPERSCREEN = 64;
MMBez : Array[0..MAXBARSPERSCREEN-1] of TAnnotationTool;

for i := 0 to globdat.vBarConf.nBalken - 1 do begin
MMBez := TAnnotationTool.Create( Chart1 );
MMBez.Text := Format( '%d', );
MMBez.Top := 30;
MMbez.Left := i * 50;
MMBez.Height := 10;
MMBez.Width := 40;
MMBez.Active := true;
MMBez.Visible := true;
end;

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jun 29, 2006 8:42 am

Hi mtspp,

This is because the tools are not properly added to the chart. You can do this:

Code: Select all

uses TeeTools;

procedure TForm1.FormCreate(Sender: TObject);
const
  MAXBARSPERSCREEN = 64;
var
  MMBez : Array[0..MAXBARSPERSCREEN-1] of TTeeCustomTool;
  i: Integer;
begin

  for i := 0 to Length(MMBez)-1 do begin
    MMBez[i] := Chart1.Tools.Add(TAnnotationTool.Create( self ));
    with (MMBez[i] as TAnnotationTool) do begin
      Text := Format( '%d', [i] );
      Top := 30;
      Left := i * 50;
      Height := 10;
      Width := 40;
      Active := true;
      Visible := true;
    end;
  end;

end;

or this:

Code: Select all

uses TeeTools;

procedure TForm1.FormCreate(Sender: TObject);
const
  MAXBARSPERSCREEN = 64;
var
  MMBez : Array[0..MAXBARSPERSCREEN-1] of TAnnotationTool;
  i: Integer;
begin

  for i := 0 to Length(MMBez)-1 do begin
    MMBez[i] := TAnnotationTool.Create( self );
    with MMBez[i] do begin
      Text := Format( '%d', [i] );
      Top := 30;
      Left := i * 50;
      Height := 10;
      Width := 40;
      Active := true;
      Visible := true;
    end;
    Chart1.Tools.Add(MMBez[i]);
  end;

end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply