Need to detect the Parent Form in Delphi (FireMonkey 3) for any Control on this form.
What is the easiest way for it?
The Root property of a control points to the uppermost Parent.
Root is of interface type IRoot. Calling GetObject on it results in the Form. The Form can be of type TCustomForm, TCustomForm3D, TForm, TForm3D, all which have TCommonCustomForm as ancestor:
function GetParentForm(Control: TFmxObject): TCommonCustomForm;
begin
if (Control.Root <> nil) and
(Control.Root.GetObject is TCommonCustomForm) then
Result := TCommonCustomForm(Control.Root.GetObject)
else
Result := nil;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With