TFrameStand
TFrameStand copied to clipboard
Use TFormClass to instantiate a Form
I had a need to use a TFormClass to instantiate a Form in TFormStand so I added a new method.
Return a TFormInfo<TForm> is reasonable for me since my form implement an interface I used to communicate to them.
The reason I needed it is I have a set of Forms I register with my system at startup and I instantiate the form based upon user selection and I need to form(s) to go in the same container.
I basically have a TDictionary<String, TFormClass> I used to select from.
With this be something reasonable to add to TFormStand?
function TFormStand.New(const FormClass: TFormClass; const AParent: TFmxObject; const AStandStyleName: string): TFormInfo<TForm>; var LForm: TForm; LParent: TFmxObject; LStandName: string; begin LParent := AParent; if not Assigned(LParent) then LParent := GetDefaultParent; LStandName := AStandStyleName; LForm := FormClass.Create(nil); try LForm.Name := ''; Result := Use<TForm>(LForm, LParent, LStandName); Result.FormIsOwned := True; except LForm.Free; raise; end;
end;
Same issue for Frames.