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

# TCustomForm.MoveToDefaultPosition

Moves the form to the location specified in the Position property.

## Declaration

Source position: forms.pp line 660

`protected procedure TCustomForm.MoveToDefaultPosition; virtual;`

## Description

MoveToDefaultPosition is a method used to move a form instance to the location specified in its Position property. It ensures that the form appears on the correct monitor for the values in the DefaultMonitor and Position properties.

DefaultMonitor is used to determine whether the form needs to be moved to a different monitor for the value in Position. For instance:

dmDesktop
  The form does not need to be moved, and the current monitor is used.
dmPrimary
  The PrimaryMonitor in Screen is used to display the form.
dmMainForm
  If the Application has a MainForm, the monitor for the main form is used. Otherwise, the form is not relocated to another monitor.
dmActiveForm
  If the Screen has an ActiveForm, the monitor for the active form is used. Otherwise, the form is not moved to another monitor.

Position specifies an associated form and the relative position for the relocated form instance. For instance:

poOwnerFormCenter
  Uses the Owner form to center align the relocated form instance. If the Owner is not a TCustomForm instance, Position is converted to poMainFormCenter to center the form to the MainForm in the application.
poMainFormCenter
  Centers the form to the MainForm for the Application. When not assigned, Position is converted to poScreenCenter to center the form on the Screen.
poScreenCenter
  Centers the form on the default monitor.
poDesktopCenter
  Centers the form to the desktop (width for all screens).
poWorkAreaCenter
  Centers the form on work area for the default monitor.
poDesigned, poDefaultSizeOnly
  Ignored in the method.
poDefault, poDefaultPosOnly
  Uses the size / relative position provided by the widgetset class instance.

MoveToDefaultPosition gets the display rectangle for the form instance, and translates the form coordinates to the correct Monitor. SetBounds is called to apply the translated origin using the height and width for the form instance.

No actions are performed in the method when either Parent or the ParentWindow handle has been assigned for the form instance. No actions are performed in the method when WindowState contains wsFullScreen or wsMaximized.

MoveToDefaultPosition is called from the AllAutoSized, SetRestoredBounds, and UpdateShowing methods. It is also called when a new value is assigned to the Position property.

## Version info

The implementation for the method was changed in LCL version 2.3.0.

## See also

TCustomForm.Position |  | The initial placement for the form.
TCustomForm.DefaultMonitor |  | The monitor on which the form is displayed.