Forum > TAChart

getting x y coords from TChart onMouseMove

(1/2) > >>


After trying to use the OnMouseMove event of a TChart to display the X and Y coordinates in some TLabels, I discovered that the TChart OnMouseMove event is overridden in the Unit TAGraph. In Unit TAGraph I added the following line in the OnMouseMove procedure:

Unit1.Form1.Label1.Caption:= IntToStr(X)+ '  ' +IntToStr(Y);

I then added Unit1 to the uses in the Interface section of TAGraph. However compilation fails with the following message: tagraph.pas(39,1) Fatal: Can't find unit Unit1 used by TAGraph. Presumably this is because TAGraph resides in a different folder than the project?

Any Ideas How I make Unit1 visible to TAGraph?



Vincent Snijders:
You cannot do that. Packages are compiled seperated from the main program and files from a project can depend (=use) on files in a package, but not the other way around.

Thanks Vincent, So how can I get the x y coords from the mouse movement if the OnMouseMove event is overridden on a Tchart object and I can't pass objects from my Form, to the TAGraph Unit where the OnMouseMove event is implemented?



Components should never use these events for their own use, but override the virtual MouseMove methind. What do you mean by an overridden OnMouseMove ?

Hello Marc, On line 262 of Unit TAGraph under protected, is the line:

procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; 

If I remove the override statement then x and y become available in the OnmouseMove event for my tchart (chart1) in my unit, However then the tchart Zoom functions etc. don't work anymore. I just assumed that override means override the OnMouseMove event of my chart1 component. I've most likely misunderstood something here. Any ideas?




[0] Message Index

[#] Next page

Go to full version