# 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 | integer | The specifier for a particular panel that is currently in memory. This handle will have been returned by the LoadPanel, NewPanel, or DuplicatePanel function.
ctrl | integer | The ID is the defined constant (located in the UIR header file) which was assigned to the control in the User Interface Editor, or the ID returned by the NewCtrl or DuplicateCtrl function.
makeRelativeToControl? | integer | 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.
clipCoordinatesToControl | integer | 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.
Output
Name | Type | Description
XCoordinate | integer * | On input, the original horizontal coordinate relative to the panel. On output, the adjusted horizontal coordinate.
YCoordinate | integer * | On input, the original vertical coordinate relative to the panel. On output, the adjusted vertical coordinate.

## Return Value

Name | Type | Description
status | integer | 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:
–1 to –999 | A User Interface Library error code. (Constants are available in userint.h.)
A description of any of these error codes can be obtained using the GetGeneralErrorString function in the toolbox.fp instrument driver.