Using the GetClass function with VCL / FMX not found

  

I have the following situation, project in *.bpl VCL structure. I want to adapt a screen made in FMX in this structure using LoadPackage and GetClass.

When I run form VCL after running FMX it loses reference in the GetClass function. But it can return the address that was allocated in the LoadPackage function. I couldn’t see what might be going on.

If anyone has an idea of ​​what might be happening or has been through it.

Code:

In untFormFMX.pas

initialization
RegisterClass(TForm1);

finalization
UnRegisterClass(TForm1);

In VCLForms.pas

initialization
RegisterClass(TForm2);

finalization
UnRegisterClass(TForm2);

In untPrinc.pas

procedure OpenFMXForm;
var
oFMXForm: TForm;
oFMXClass: TPersistentClass;
begin
LoadPackage(‘pctFMXForms.bpl’);
oFMXClass := GetClass(‘TForm1’);
Application.CreateForm(TFormClass(oFMXClass) ,oFMXForm );
TForm(oFMXForm).ShowModal
end;

procedure OpenVCLForm;
var
oVCLForm: TForm;
oVCLClass: TPersistentClass;
begin
LoadPackage(‘pctVCLForms.bpl’);
oVCLClass := GetClass(‘TForm2’);
Application.CreateForm(TFormClass(oVCLClass) ,oVCLForm );
TForm(oVCLForm).ShowModal
end;

Process:

1° Open VCL Form: OK
2° Open FMX Form: OK
3° Open VCL Form: not found return nil

Comments are closed.