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

# TCustomForm.SetZOrder

Moves a top-level form in front of or behind all other forms.

## Declaration

Source position: forms.pp line 660

`protected procedure TCustomForm.SetZOrder(`
`Topmost: Boolean`
`); override;`

## Arguments

`Topmost` |  | True to bring the form to the front or top of the Z-order.

## Description

SetZOrder is an overridden method in TCustomForm. It ensures that a request to bring the current form to the top of the Z-Order is handled properly.

If a Parent control has not been assigned, the form instance is moved to the top of the Z-Order in the Screen singleton and the SetForegroundWindow routine is called using the Handle for the form instance. No actions are performed in the method if the Handle has not been allocated for the control, or when another form has been displayed modally on the Screen.

If Parent has been assigned, the inherited method is called to change the Z-Order using the SetChildZPosition method in the parent control.

SetZOrder is called from the BringToFront and SendToBack methods in the TControl ancestor.

## See also

TScreen.GetCurrentModalForm |  | Returns the Modal form at the top of the Z-order for the screen.
TScreen.MoveFormToZFront |  | Moves the form to the front of the Z-order in the CustomFormsZOrdered property.
TControl.SetZOrder |  | Moves the control in front of or behind all sibling controls.
TControl.Parent |  | The control within which the control is shown.
TControl.BringToFront |  | Brings the control in front of other sibling controls.
TControl.SendToBack |  | Moves all sibling controls in front of this control.
SetForegroundWindow |  | Moves a window in front of all other windows, and activates it.