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

# ValidParentForm

Gets a valid parent form for the specified control.

## Declaration

Source position: forms.pp line 1972

`function ValidParentForm(`
`Control: TControl;`
`TopForm: Boolean = True`
`):TCustomForm;`

## Arguments

`Control` |  | Control examined in the routine.
`TopForm` |  | True if all parent forms are located in the routine.

## Function result

Form instance that is the parent form for the control.

## Description

ValidParentForm is a TCustomForm function used to get a valid parent form for the control specified in the Control argument. TopForm indicates if the return value should contain the absolute root ancestor in the ancestry tree. ValidParentForm calls GetParentForm to get the return value for the routine.

ValidParentForm raises an EInvalidOperation exception with the message in sParentRequired when a valid parent form is not found for the specified control.

## Errors

Raises an EInvalidOperation exception with the message in sParentRequired when a valid parent form is not found for the specified control.