KingOrmon Posted March 26, 2014 Share Posted March 26, 2014 Hello, I would like to load DFM files at runtime, for allows me modify uniforms without recompile. I am trying to load without succes via this function: procedure LoadComponentFromFile(Component: TComponent; const FileName: TFileName); var FileStream : TFileStream; MemStream : TMemoryStream; i: Integer; begin MemStream := nil; if not Assigned(Component) then raise Exception.Create('Component is not assigned'); if FileExists(FileName) then begin FileStream := TFileStream.Create(FileName,fmOpenRead); try for i := Component.ComponentCount - 1 downto 0 do begin if Component.Components[i] is TControl then TControl(Component.Components[i]).Parent := nil; Component.Components[i].Free; end; MemStream := TMemoryStream.Create; ObjectTextToBinary(FileStream, MemStream); MemStream.Position := 0; MemStream.ReadComponent(Component); Application.InsertComponent(Component); finally MemStream.Free; FileStream.Free; end; end; end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 27, 2014 Share Posted March 27, 2014 Hi KingOrmon. can will help (you may have already have looked these links...) http://stackoverflow.com/questions/19989389/can-we-load-a-dfm-file-for-a-form-at-runtime http://stackoverflow.com/questions/3163586/best-way-to-save-restore-a-form-foss Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.