method Surface.PointToPosition (ByRef X as Long, ByRef Y as Long)
Converts display coordinates to element's position.

TypeDescription
X as Long (By Reference) A Long expression that determines the x-coordinate on the screen. On return it gets the x-coordinate on the surface.
Y as Long (By Reference) A Long expression that determines the y-coordinate on the screen. On return it gets the y-coordinate on the surface.
Use the PointToPosition / PositionToPoint property to convert screen coordinates to surface coordinates or reverse. The PointToPosition / PositionToPoint convert the giving point based on the ScrollX, ScrollY and Zoom conditions ( scroll position and the zooming factor of the surface ). If X and Y are -1, on return the X and Y defines the surface coordinates. The ElementFromPoint property gets the element from the surface giving the position on the surface. The ElementFromPoint(-1,-1) property returns the element from the cursor or nothing if no element at the current cursor position. On PowerBuilder, or any other environment that does not support parameters by reference you can use the ExecuteTemplate method. For instance, you can use a code like ExecuteTemplate("dim x,y;x=-1;y=-1;PointToPosition(x,y);x") that returns the x-position (surface's coordinates) of the current mouse pointer. In the same manner you can use ExecuteTemplate("dim x,y;x=-1;y=-1;PointToPosition(x,y);y") to return the y-position.