# GetMonitorFromRect

int GetMonitorFromRect (Rect rectangle, int *monitorID);

## Purpose

Returns the ID of the monitor that contains the specified rectangle or is nearest to the specified rectangle.

If the rectangle is on more than one monitor, the function returns the monitor that contains the majority of the rectangle.

## Parameters

Input
Name | Type | Description
rectangle | Rect | A Rect structure. The Rect structure is defined as follows: typedef struct { int top; int left; int height; int width; } Rect; You can create a Rect without having to declare a variable by using the following function: Rect MakeRect (int top, int left, int height, int width);
Output
Name | Type | Description
monitorID | integer (passed by reference) | The ID of the monitor that contains the majority of the specified rectangle or is nearest to the specified rectangle.

## Return Value

Name | Type | Description
status | integer | Return value indicating whether the function was successful. A negative number indicates that an error occurred.
Code | Error Message String
xx | Success