Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TFormClass to instantiate a Form #52

Open
MarkBracey opened this issue Nov 24, 2019 · 1 comment
Open

Use TFormClass to instantiate a Form #52

MarkBracey opened this issue Nov 24, 2019 · 1 comment

Comments

@MarkBracey
Copy link

I had a need to use a TFormClass to instantiate a Form in TFormStand so I added a new method.

Return a TFormInfo 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;
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(LForm, LParent, LStandName);
Result.FormIsOwned := True;
except
LForm.Free;
raise;
end;

end;

@poyop
Copy link

poyop commented Mar 28, 2021

Same issue for Frames.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants