I want to create a form given its class name as a string, which has been asked about before, but instead of calling GetClass
, I want to use Delphi's new RTTI feature.
With this code, I've got a TRttiType
, but I don't know how to instantiate it.
var
f:TFormBase;
ctx:TRttiContext;
lType:TRttiType;
begin
ctx := TRttiContext.Create;
for lType in ctx.GetTypes do
begin
if lType.Name = 'TFormFormulirPendaftaran' then
begin
//how to instantiate lType here?
Break;
end;
end;
end;
I've also tried lType.NewInstance
with no luck.
Show()
method. Just call it normally:f.Show;
– Wendelina