GetGraphCoordsFromPoint

int GetGraphCoordsFromPoint (int panel, int control, point point, double *x, double *y);

Purpose

Converts pixel coordinates within the panel to graph coordinates. This function is useful for converting the mouse position coordinates that GetRelativeMouseState returns. The return value indicates whether the point is within the graph plot area.

Parameters

Input
Name Type Description
panelHandle integer Specifier for a particular panel that is currently in memory. You obtain this handle from LoadPanel, NewPanel, or DuplicatePanel.
controlID integer The defined constant, located in the .uir header file, that you assigned to the control in the User Interface Editor, or the ID returned by NewCtrl or DuplicateCtrl.
point Point A Point structure specifying the coordinates of a point in the panel containing the graph control.

The Point structure is defined as follows:

typedef struct
   {
   int x;
   int y;
   } Point;


You can create a Point without having to declare a variable by using the following function:

Point MakePoint (int x, int y);

The following example shows how to use MakePoint with GetGraphCoordsFromPoint. In this example, eventData1 is the vertical mouse position, and eventData2 is the horizontal mouse position.

GetGraphCoordsFromPoint (panelHandle, graphControlID, MakePoint (eventData2, eventData1), &x, &y);

Output
Name Type Description
X double * The x component of the point, translated to graph coordinates.

Y double * The y component of the point, translated to graph coordinates.

Return Value

Name Type Description
status integer Returns zero to indicate that the point is outside the plot area and one to indicate that the point is within the plot area. A negative number indicates that an error occurred.