Title: Storing TForm and/or its properties in a BLOB
Question: Storing TForm and/or its properties in a BLOB
Answer:
Here are examples you need:
procedure SaveToField(FField:TBlobField;Form:TComponent);
var
Stream: TBlobStream;
FormName: string;
begin
FormName := Copy(Form.ClassName, 2, 99);
Stream := TBlobStream.Create(FField, bmWrite);
try
Stream.WriteComponentRes(FormName, Form);
finally
Stream.Free;
end;
end;
procedure LoadFromField(FField:TBlobField;Form:TComponent);
var
Stream: TBlobStream;
I: integer;
begin
try
Stream := TBlobStream.Create(FField, bmRead);
try
{delete all components}
for I := Form.ComponentCount - 1 downto 0 do
Form.Components[I].Free;
Stream.ReadComponentRes(Form);
finally
Stream.Free;
end;
except
on EFOpenError do {nothing};
end;
end;