[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Forms' (#lcl)

# TWindowMagnetManager.SnapToMonitor

Snaps a window to an edge on the monitor.

## Declaration

Source position: forms.pp line 443

`protected function TWindowMagnetManager.SnapToMonitor(`
`Opts: TWindowMagnetOptions;`
`var WindowPos: TWindowPos`
`):Boolean;`

## Arguments

`Opts` |  | Snapping options used in the method.
`WindowPos` |  | Structure with the window handle, position, and flags for the form affected in the method. The variable parameter can be updated in the method.

## Function result

Returns True if the form was successfully snapped to a monitor edge in the method. Returns False if SnapToMonitor is not enabled in the Opts parameter.

## Description

SnapToMonitor converts the window position information in WindowPos to a TRect instance used to locate the monitor and position on its work area. The SnapToSides method is called to adjust the window position when snapping behavior is applied for the window.

The return value is True if the window was successfully snapped to an edge on a monitor, and value(s) in WindowPos were changed.

No actions are performed in the method if SnapToMonitor is not enabled in the Opts argument. In this case, the return value is False.