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

TWindowMagnetManager.SnapForm

Snaps the specified form to the nearest snap target.

Declaration

Source position: forms.pp line 448

public function TWindowMagnetManager.SnapForm(

  Form: TCustomForm;

  var WindowPos: TWindowPos

):Boolean;

Arguments

Form

  

Form instance examined and updated in the method.

WindowPos

  

Structure with the window handle and position examined and updated in the method.

Function result

Returns True if the specified form was repositioned (or resized) due to snapping behavior for the form or application.

Description

No actions are performed in the method when the Enabled property is set to False, when the window flags indicate that the window is being shown or hidden, or at design-time.

SnapForm calls the GetCompositorExtendedBorder routine to determine if the size for the window is inaccurate for borders or shadows added by the compositor for the desktop window manager. Both the SnapToMonitor and SnapToForms methods are called to determine the return value for the method.

The return value is True if the window position was snapped to either an edge on the monitor or another form instance in the application.

SnapForm is called from the WMWindowPosChanging method when a LM_WINDOWPOSCHANGING message is received and handled for a form instance.

Remark: In the current LCL release, the LM_WINDOWPOSCHANGING message is dispatched for the Windows platform only. None of the other widgetsets checked for or apply the message.

See also

TWindowMagnetManager.Enabled

  

Enables or disables form and/or screen snapping behavior using the manager class.

TWindowMagnetManager.SnapToMonitor

  

Snaps a window to an edge on the monitor.

TWindowMagnetManager.SnapToForms

  

Snaps a form to an edge on another form in the application which is a valid snap target.


Version 4.0 Generated 2025-05-03 Home