Hello Cheryll,
Sorry for the dealy.
And why do you need my code? This question has nothing to do with my code.
We wanted see the code are you using, because it would be very useful for us to find an accurate solution based in your code.
1) How can I addres "Fadenkreuz" from another unit?
To address your cursor from another unit, you have to declare the tool as public in your unit and add this unit in the uses clause on the unit where you want to access the tool.You can do something as next:
Tool declaration:
Code: Select all
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,Chart, CandleCh, Series, TeeTools;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
MyCursor:TCursorTool;
end;
Call the tool from other unit:
Firstly, add the unit1 in the uses clause on the unit where you want to access the tool. The lines code below show how you can do it:
Code: Select all
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,Unit1...
Then you need only call the tool as do next:
Code: Select all
procedure TForm2.FormCreate(Sender: TObject);
begin
Form1.MyCursor.Pen.Color := clRed;
End;
2) How can I find out the items number (in our case zero) of Fadenkreuz later on?
(in my software there will be checkboxes to check and uncheck different drawing tools).
The best way to get the tools indexes there are in Chart, is use a loop to search tool index you want; in your case, cursor tool. The code below shows how you can do it.
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var i,indexCursor:Integer;
begin
Chart1:=TChart.Create(Self);
Chart1.Parent:=Self;
Chart1.Align:=alClient;
Chart1.View3D:=false;
Chart1.Legend.Visible:=false;
candle1:=Chart1.AddSeries(TCandleSeries) as TCandleSeries;
candle1.FillSampleValues;
line1:=Chart1.AddSeries(TLineSeries) as TLineSeries;
rsiFunc1:=TRSIFunction.Create(Self);
line1.SetFunction(rsiFunc1);
line1.DataSource:=candle1;
Chart1.Tools.Add(TDrawLineTool);
Chart1.Tools.Add(TCursorTool);
for i := 0 to Chart1.Tools.Count-1 do
If Chart1.Tools[i] is TCursorTool then
indexCursor:= i;
MyCursor := Chart1.Tools.Items[indexCursor] as TCursorTool;
MyCursor.Series := line1;
end;
Also, I would like inform you that "Tools" are small objects that perform additional charting functionality, like interactive drawing of lines, mouse rotation, etc. Therefore, you don’t have access to own tools through Chart and the code you use in the lines below is incorrect:
Code: Select all
// Chart_MP.Fadenkreuz:=candle1;
// Chart_MP.Tools.Fadenkreuz:=candle1;
// Chart_MP.Tools.Item.Fadenkreuz:= candle1;
The only code line you have attached me that should work without problems is next:
There is more information about TeeChart tools in the help documentation. You find the help documentation in a similar path as next:
%Program Files%\ Steema Software\TeeChart 2014 for RAD XE6\Docs
I would need an OnChange event on my "Fadenkreuz" to synchronzise it with a subchart crosshair.The procedure is ready and looks fine, but I have no idea, how to fit the onChange event. At the moment I am not able to pass on "Fadenkreuz" with proper values. They stay zero.
I would like inform you that when you create an own tool that is based in a specifically tool, you can use same methods and events there are implemented in base tool. Therefore, you should use OnChange event and do the same as do in Demo example All Features\Tools\Cursor\Synchronizing Two.