2018年5月7日 星期一

delphi 把個 物件 元件 object component 存檔 save file

http://www.swissdelphicenter.ch/en/showcode.php?id=1626
https://stackoverflow.com/questions/698536/saving-a-tobject-to-a-file
https://torry.net/pages.php?id=96
http://jedqc.blogspot.tw/2006/02/d2006-what-on-earth-are-these-explicit.html
http://www.jed-software.com/files/ExplicitProps.zip
delphi runtime design system save
http://bitwisemag.co.uk/2/Add-A-Runtime-Form-Designer-To.html
delphi component stream binary save
http://www.delphisources.ru/pages/faq/master-delphi-7/content/LiB0045.html
https://theroadtodelphi.com/tag/rtti/
delphi property procedure save file Method
如何欺騙 Delphi 將一般獨立 procedure 當成 TxxEvent of Class;
Using resource files with Delphi
delphi component stream serialization
https://www.thoughtco.com/function-or-procedure-as-parameter-1057606

...save a TImagelist with all its images to a file?


// For writing components use WriteComponentResFile(path + source filename , component name source)
WriteComponentResFile('C:\imagelist1.bin',imagelist1);

// For reading the data back to a component:
// component := ReadComponentResFile(path + source filename , component name traget)
imagelist1 := ReadComponentResFile('c:\imagelist1.bin', nilas TImagelist;


function ComponentToString(Component: TComponent): string;

var
BinStream:TMemoryStream;
StrStream: TStringStream;
s: string;
begin
BinStream := TMemoryStream.Create;
try
StrStream := TStringStream.Create(s);
try
BinStream.WriteComponent(Component);
BinStream.Seek(0, soFromBeginning);
ObjectBinaryToText(BinStream, StrStream);
StrStream.Seek(0, soFromBeginning);
Result:= StrStream.DataString;
finally
StrStream.Free;

end;
finally
BinStream.Free
end;
end;