ConvertMouseCoordinates
int ConvertMouseCoordinates (int panel, int ctrl, int makeRelativeToControl, int clipCoordinatesToControl, int *xCoordinate, int *yCoordinate);
Purpose
When control callback functions receive mouse events, eventData1 and eventData2 contain the vertical and horizontal mouse coordinates, respectively. The coordinate values are relative to the top left corner of the panel under the title bar and within the frame.
This function allows you to adjust the coordinates so that they are relative to the top and left coordinates of a control on the panel. It also allows you to restrict the coordinates to the rectangular area defined by the top, left, width, and height of the control.
Parameters
Input | ||
Name | Type | Description |
panel | int | The specifier for a particular panel that is currently in memory. You obtain this handle from LoadPanel, NewPanel, or DuplicatePanel. |
ctrl | 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 NewCtrl or DuplicateCtrl. |
makeRelativeToControl | int | This parameter specifies whether you want the mouse coordinates, which are assumed to be relative to the panel, to be adjusted to be relative to the top and left coordinates of the control. Specify a nonzero value or select Yes in the function panel to make the mouse coordinates relative to the control. Specify 0 or select No in the function panel to make the mouse coordinates relative to the panel. |
clipCoordinatesToControl | int | This parameter specifies whether you want the mouse coordinates to be restricted to the rectangular area defined by the size of the control. This option causes coordinates outside the control to be adjusted to the closest point on the rectangle defined by the top, left, height, and width of the control. Specify a nonzero value or select On in the function panel to restrict the mouse coordinates. Specify 0 or select Off in the function panel if you do not want to restrict the mouse coordinates. |
Output | ||
Name | Type | Description |
xCoordinate | int | On input, the original horizontal coordinate relative to the panel. On output, the adjusted horizontal coordinate. |
yCoordinate | int | On input, the original vertical coordinate relative to the panel. On output, the adjusted vertical coordinate. |
Return Value
Name | Type | Description | ||
status | int | Returns zero if the extended mouse events were enabled for the control, or a negative error code if the function failed. The possible negative error codes are:
A description of any of these error codes can be obtained using the GetGeneralErrorString function in the toolbox.fp instrument driver. |
Additional Information
Library: Programmer's Toolbox
Include file: toolbox\toolbox.h
LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later