Recent

Author Topic: TDoublePoint in Chart  (Read 3787 times)

svdg

  • Newbie
  • Posts: 2
TDoublePoint in Chart
« on: November 08, 2017, 06:10:05 pm »
Maybe I'm not right here with my question and maybe it's a stupied question.
I want to get the x,y position under the mouse cursor in an xy chart. I find several solutions on this board, but they nearly always fall back on introducing a variable type TDoublePoint.
If I do this, I get the error : Identifier not found "TDoublePoint".
I'm using Lazarus 1.6 under Windows 10 and Linux and get the same error.
Did I forget something?
Any help would be appreciated.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: TDoublePoint in Chart
« Reply #1 on: November 08, 2017, 06:41:41 pm »
You don't say which XY chart component you are using.
If it does not provide an OnMouseMove event, then you can use some adaptation of this:
Code: Pascal  [Select][+][-]
  1. uses ...LCLIntf, ...;
  2.  
  3. ...
  4. var
  5.   pt: TPoint;
  6. begin
  7.   if GetCursorPos(pt) then begin
  8.     pt:=ScreenToClient(pt);
  9.     WriteLn('mouseX=',pt.x,', mouseY=',pt.y); // or use pt.x, pt.y to suit your need
  10.   end;
  11. end;

The raw pt value is a screen coordinate, so for most uses needs to be transformed into coordinates appropriate to your form or control.
« Last Edit: November 08, 2017, 06:43:56 pm by howardpc »

wp

  • Hero Member
  • *****
  • Posts: 11910
Re: TDoublePoint in Chart
« Reply #2 on: November 08, 2017, 06:48:27 pm »
TDoublePoint is declared in TAChartUtils - this is the first place to look for declarations not found. Other often-seeked units are TACustomSeries, TACustomSource and TAGeometry.

"Secret" hint: Click on these words in the uses clause with the CTRL key down to open these units in the source editor - now you can browse and see which treasures they contain (works, of course, throughout any source file).

svdg

  • Newbie
  • Posts: 2
Re: TDoublePoint in Chart
« Reply #3 on: November 08, 2017, 10:43:06 pm »
Thanks a lot!

 

TinyPortal © 2005-2018