需要引用单元:Vcl.Forms
function GetParentForm(Control: TControl; TopForm: Boolean = True): TCustomForm;
示例:
GetParentForm(Edit1);