procedure TFrame2.bnSecondClick(Sender: TObject); var wc: TWinControl; begin wc := Parent; repeat if wc.InheritsFrom(TForm) then Break else wc := wc.Parent; until Parent.InheritsFrom(TForm); ShowMessage(wc.Name); end;
procedure TFrame2.bnSecondClick(Sender: TObject); var wc: TWinControl; begin wc := Parent; while not wc.InheritsFrom(TForm) do wc := wc.Parent; ShowMessage(wc.Name); end;
uses Forms; function GetParentForm(Control: TControl; TopForm: Boolean = True): TCustomForm;
procedure TFrame2.bnSecondClick(Sender: TObject); var wc: TWinControl; begin wc := Parent; while not wc.InheritsFrom(TForm) do // ws = nil - AV wc := wc.Parent; ShowMessage(wc.Name); end;