вот такой код я использую для подгрузки DFM
раньше был очень короткий но заглючил с девками
https://www.devexpress.com/Support/Center/Question/Details/T275318
поэтому пришлось чуть поменять дельфовскуй исходную InitInheritedComponent1
constructor TForm11.Create(AOwner: TComponent); // override;
Inherited CreateNew(AOwner);
if (ClassType <> TForm11) and not(csDesigning in ComponentState) then
if not InitInheritedComponent1(Self, TForm) then
raise EResNotFound.CreateFmt('TForm11 res', [ClassName]);
OldCreateOrder := False;
function InternalReadComponentRes1(const ResName: UnicodeString;
HInst: THandle; var Instance: TComponent): Boolean; overload;
var
HRsrc: THandle;
begin { avoid possible EResNotFound exception }
if HInst = 0 then
HInst := HInstance;
HRsrc := FindResourceW(HInst, PWideChar(ResName), PWideChar(RT_RCDATA));
Result := HRsrc <> 0;
if not Result then
Exit;
with TResourceStream.Create(HInst, ResName, RT_RCDATA) do
try
Instance := ReadComponent(Instance);
finally
Free;
end;
Result := True;
end;
function ReadFromDFM(filename: UnicodeString;
var Instance: TComponent): Boolean;
var
fs: TFileStream;
Buffer: array [0 .. 0] of Byte;
ms: TMemoryStream;
begin
fs := TFileStream.Create(filename, fmOpenRead);
fs.Read(Buffer, 1); // read the first 4 bytes
fs.Seek(0, 0);
if Buffer[0] <> $FF then
begin // is it a DFM resource?
ms := TMemoryStream.Create;
ObjectTextToBinary(fs, ms);
ms.Seek(0, soFromBeginning);
ms.ReadComponent(Instance);
ms.Free;
fs.Free;
end
else
begin
fs.Free;
ReadComponentResFile(filename, Instance);
end;
end;
function InitInheritedComponent1(Instance: TComponent;
RootAncestor: TClass): Boolean;
function InitComponent1(ClassType: TClass): Boolean;
begin
Result := False;
if (ClassType = TComponent) or (ClassType = RootAncestor) then
Exit;
Result := InitComponent1(ClassType.ClassParent);
if ClassType.ClassParent.ClassParent = TForm11 then
Result := ReadFromDFM( ClassType.UnitName + '.dfm',
Instance) or Result
else
Result := InternalReadComponentRes1(ClassType.ClassName,
FindResourceHInstance(FindClassHInstance(ClassType)), Instance)
or Result;
end;
var
LocalizeLoading: Boolean;
begin
GlobalNameSpace.BeginWrite; // hold lock across all ancestor loads (performance)
try
LocalizeLoading := (Instance.ComponentState * [csInline, csLoading]) = [];
if LocalizeLoading then
BeginGlobalLoading; // push new loadlist onto stack
try
Result := InitComponent1(Instance.ClassType);
if LocalizeLoading then
NotifyGlobalLoading; // call Loaded
finally
if LocalizeLoading then
EndGlobalLoading; // pop loadlist off stack
end;
finally
GlobalNameSpace.EndWrite;
end;
end;