You should use the TRttiContext.FindType() method instead of manually navigating through the TRttiContext.GetTypes() list, for example:
lType := ctx.FindType('ScopeName.UnitName.TFormFormulirPendaftaran'); if lType <> nil then begin ... end;
But in any case, as soon as you place TRttiType for the desired class type, you can create it this way:
type TFormBaseClass = class of TFormBase; f := TFormBaseClass(GetTypeData(lType.Handle)^.ClassType).Create(TheDesiredOwnerHere);
Or this if TFormBase obtained from TForm :
f := TFormClass(GetTypeData(lType.Handle)^.ClassType).Create(TheDesiredOwnerHere);
Or this if TFormBase is derived from TCustomForm :
f := TCustomFormClass(GetTypeData(lType.Handle)^.ClassType).Create(TheDesiredOwnerHere);
Update: Or, as shown in @RRUZ's figure. This is more TRttiType oriented and does not rely on the use of functions from the older TypInfo module.
Remy Lebeau
source share