But I have no declaration of class TGoodForm (I get instance from runtime library), and compiler doesn't know about TGoodForm::TGoodForm.
But I found the solution:
The solution is to create delphi function which calls virtual constructor
// delphi unit ComponentCreator.pas
unit ComponentCreator;
interface
uses Classes;
function ComponentCreate(cls: TComponentClass; Owner: TComponent): TComponent;
implementation
function ComponentCreate(cls: TComponentClass; Owner: TComponent): TComponent;
begin
ComponentCreate:=cls.Create(Owner);
end;
end.
// C++ unit
#include "ComponentCreator.hpp"
TClass newClass=existingComponent->ClassType();
RegisterClass(newClass);
TComponent* newComponent=ComponentCreate(newClass, form);
UnRegisterClass(newClass);
newComponent->Name=newName;
// It was useful to analyze VCL source file "Classes.pas"