Make TCursorTool perform OnChange Event?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
tbonejo
Newbie
Newbie
Posts: 73
Joined: Wed Sep 06, 2006 12:00 am
Contact:

Make TCursorTool perform OnChange Event?

Post by tbonejo » Tue Jan 23, 2007 1:09 pm

Is there a possible way to execute the OnChange event of the TCursor Tool from else where in my code?

I am updating labels showing the output this change and as doing the updat would like that event to execute WITHOUT actually moving a cursor.

Is this possible?


Thanks,


Tom
Tom

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 Jan 23, 2007 1:47 pm

Hi Tom,

Yes, you can do something like this:

Code: Select all

procedure TForm1.ChartTool1Change(Sender: TCursorTool; x, y: Integer;
  const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
begin
  Chart1.Title.Text.Add('Cursor Changed');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if ((X0 <> -1) and (Y0 <> -1)) then
  begin
    ChartTool1Change(ChartTool1, X0, Y0, Chart1.Axes.Bottom.CalcPosPoint(X0),
                    Chart1.Axes.Bottom.CalcPosPoint(X0), ChartTool1.Series,
                    ChartTool1.Series.Clicked(X0,Y0));
  end;
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  X0:=X;
  Y0:=Y;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  X0:=-1;
  Y0:=-1;
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

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 Jan 23, 2007 3:22 pm

Hi Tom,

Sorry but the tool's event call should be something like this:

Code: Select all

    ChartTool1Change(ChartTool1, X0, Y0, Chart1.Axes.Bottom.CalcPosPoint(X0),
                    Chart1.Axes.Left.CalcPosPoint(Y0), ChartTool1.Series,
                    ChartTool1.Series.Clicked(X0,Y0));
I forgot to change the YValue argument after copy and paste :wink:.
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

tbonejo
Newbie
Newbie
Posts: 73
Joined: Wed Sep 06, 2006 12:00 am
Contact:

Post by tbonejo » Wed Jan 24, 2007 11:45 am

Thats ok, I got it working nice and smooth.


Thanks,

Tom
Tom

Post Reply