Scalabium Software

SMReport Autogenerated
Knowledge for your independence'.
Home Delphi and C++Builder tips


#65: How can I save/restore the component into BLOB-field?

Sometimes in applications you must save the component into BLOB-field of the own table and in run-time to restore it. For example, to save the report form and in run-time the end-user will select the wished report before report generation.

The next two procedure allows to save the component with all properties and restore it.

procedure SaveCompToBlob(AField: TBlobField; AComponent: TComponent);
var
  Stream: TBlobStream;
  CompName: string;
begin
  CompName := Copy(AComponent.ClassName, 2, 99);
  Stream := TBlobStream.Create(AField, bmWrite);
  try
    Stream.WriteComponentRes(CompName, AComponent);
  finally
    Stream.Free;
  end;
end;

procedure LoadCompFromBlob(AField: TBlobField; AComponent: TComponent);
var
  Stream: TBlobStream;
  i: integer;
begin
  try
    Stream := TBlobStream.Create(AField, bmRead);
    try
      {delete the all child components}
      for i := AComponent.ComponentCount - 1 downto 0 do
        AComponent.Components[i].Free;
      Stream.ReadComponentRes(AComponent);
    finally
      Stream.Free;
    end;
  except
    on EFOpenError do {nothing};
  end;
end;


Published: February 11, 2000

See also
 
Clarion to Text converter
SMMsg suite
ExcelFile Viewer
dBase Viewer
Mail parser (ActiveX)
Clarion Viewer
Excel Reader (dll)
SMReport
DBISAM Password Recovery
ABA Document Convert
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2017, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising