GetGraphCoordsFromPoint
int GetGraphCoordsFromPoint (int panelHandle, int controlID, 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 pixel coordinates should be relative to the top, left corner of the panel. The return value indicates whether the point is within the graph plot area.
Supported Controls
You can use GetGraphCoordsFromPoint with graph controls.
Parameters
Input | ||
Name | Type | Description |
panelHandle | int | Specifier for a particular panel that is currently in memory. You can obtain this handle from functions such as LoadPanel and NewPanel. |
controlID | int | 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 functions such as NewCtrl and DuplicateCtrl. |
point | Point |
A Point structure specifying the coordinates of a point in the panel containing the graph control. The coordinates should be relative to the top, left corner of the panel. 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 | int | 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. |
Additional Information
Library: User Interface Library
Include file: userint.h
LabWindows/CVI compatibility: LabWindows/CVI 8.0 and later