TScreen.MonitorFromWindow function
Finds the monitor containing the form with the given window handle.
Declaration
function MonitorFromWindow(const Handle: TLCLHandle;
MonitorDefault: TMonitorDefaultTo=mdNearest)
: TMonitorArguments
Handle | The TLCLHandle instance on the monitor located in the method. |
MonitorDefault | What to return if a monitor was found. |
Function result
The TMonitor instance found for the specified handle.
Description
MonitorFromWindow is a TMonitor function used to locate the monitor where the form represented by the specified window Handle is displayed.
MonitorDefault is a
TMonitorDefaultTo enumeration value
which indicates the monitor used when the display area for the form is not
found on a monitor.
See
TMonitorDefaultTo for more
information about the values in the enumeration and their meanings.
MonitorFromWindow calls the MonitorFromWindow routine in the LCL interface to get the HMONITOR handle to locate in the Monitors property. The UpdatedMonitors method is called to ensure that Monitors contains up-to-date values for the available monitors.
If the handle is found in Monitors, the TMonitor instance with the handle is used as the return value.
If a monitor is not found, GetWindowRect is called to get the display area for the TLCLHandle specified in the Handle argument. MonitorFromRect is called to locate the monitor which contains the rectangle. The TMonitor instance is used as the return value.
MonitorFromWindow is called from methods like TCustomForm.GetMonitor.
Modified in LCL version 4.0 to use the TLCLHandle type instead of the deprecated THandle type in the Handle parameter.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
