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

TScreen.MonitorFromWindow

Finds the monitor containing the form with the given window handle.

Declaration

Source position: forms.pp line 1258

public function TScreen.MonitorFromWindow(

  const Handle: TLCLHandle;

  MonitorDefault: TMonitorDefaultTo = mdNearest

):TMonitor;

Arguments

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.

Version info

Modified in LCL version 4.0 to use the TLCLHandle type instead of the deprecated THandle type in the Handle parameter.

See also

TMonitor.Handle

  

Handle which identifies this monitor to the system.

TMonitorDefaultTo

  

The monitor to use when screen coordinates are outside of the physical bounds for the screens.

TLCLHandle

HMONITOR

  

The type of a display Monitor (CRT...) Handle.


Version 4.0 Generated 2025-05-03 Home