Page 1 of 1

Coordinates

Posted: Wed May 07, 2008 4:05 pm
by 6927799
How can I convert from teeChart screen coordinates to VisualBasic form screen coordinates?
I want to position a control in a form in a click on the teeChart.

thank you

Posted: Thu May 08, 2008 9:26 am
by yeray
Hi Hermes,

You could convert chart screen coordinates to form screen coordinates simply adding the chart's position to the desired coordinate. Something like this:

Code: Select all

FormXCoord = ChartXCoord + TChart1.Left
FormYCoord = ChartYCoord + TChart1.Top
But note that chart coordinates are expressed in pixels and the form in twips (15 pixels). So you should make your form count in pixels as follows:

Code: Select all

Me.ScaleMode = vbPixels
Or you could also count chart coordinates by 15 on 15:

Code: Select all

FormXCoord = ChartXCoord * 15 + TChart1.Left
FormYCoord = ChartYCoord * 15 + TChart1.Top