Add / Remove TRectangle Tools during RunTime

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Krishna
Newbie
Newbie
Posts: 16
Joined: Mon Jun 12, 2006 12:00 am
Contact:

Add / Remove TRectangle Tools during RunTime

Post by Krishna » Mon Sep 11, 2006 6:52 am

Please help me... Its urgent

We are developing a VCL Component.
In the constructor I'm creating a Rectangle tool like:

EditTextTool : TRectangleTool;
self.EditTextTool := TRectangleTool.Create(self);

While dragging the component from the pallete(during design time), the constructor is being called and the tool was created.

When we run the application, the constructor is called again, and one more tool was created.

How can I find any existing tools and remove them, before creating new ones...???

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

Post by Narcís » Tue Sep 12, 2006 9:04 am

Hi Krishna,

You can try doing something like this:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  RectTool: TRectangleTool;
  i: Integer;
begin
  if Chart1.Tools.Count > 0 then
    for i:=Chart1.Tools.Count-1 downto 0 do
      if (Chart1.Tools[i] is TRectangleTool) then
        Chart1.Tools[i].Free;

  RectTool:=TRectangleTool.Create(self);
  Chart1.Tools.Add(RectTool);
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