How to store TForms and / or their properties in a Paradox blob field (Views: 30)
Problem/Question/Abstract: How to store TForms and / or their properties in a Paradox blob field Answer: 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; |