Board index » delphi » Storing TForm and/or its properties in a BLOB

Storing TForm and/or its properties in a BLOB

Hi,

this time I have a question.

I am looking for a solution to efficiently storing a Form's and it's
components' properties in a BLOB field or other binary file (possibly created
with a TStream).

I don't want to use DLLs other anything else, but simply create a form with
certain properties, and then use the components on the form and adjust their
properties, almost like the DFM format of the Delphi family.

Is that possible in runtime? Mail me at ow...@ellipse-data.com with
suggestions. Feel free to post on the Usenet groups, due to the fact that I
also browse around here quite often.

Stefan

 

Re:Storing TForm and/or its properties in a BLOB


Quote
In article <N.100496.215247.82@thelink>, del...@iafrica.com (Me) wrote:
>Hi,

>this time I have a question.

>I am looking for a solution to efficiently storing a Form's and it's
>components' properties in a BLOB field or other binary file (possibly created
>with a TStream).

>I don't want to use DLLs other anything else, but simply create a form with
>certain properties, and then use the components on the form and adjust their
>properties, almost like the DFM format of the Delphi family.

>Is that possible in runtime? Mail me at ow...@ellipse-data.com with
>suggestions. Feel free to post on the Usenet groups, due to the fact that I
>also browse around here quite often.

Get a copy of "Secrets of Delphi 2.0"

John

World-Wide-Web: The CB Radio of the 90's

Re:Storing TForm and/or its properties in a BLOB


On 05/10/1996 01:44, in message <5347nj$...@mtinsc01-mgt.ops.worldnet.att.net>,
John M. Miano <mi...@worldnet.att.net> wrote:

Quote
> Get a copy of "Secrets of Delphi 2.0"

Is that all you can say? A VERY good tip *sarcastic look*.

*begin-of-flame*
We do not have all the possibilities here in South Africa. The stuff has to be
imported. If the importer feels there is not enough market they simply wont
import the book. So if you don't mind, please provide a HELPFUL hint (Do you
think I wouldn't buy the book if I had the chance?).
*end-of-flame*

Thank you

Stefan

P.S. I apologise for any discomforts caused.

Re:Storing TForm and/or its properties in a BLOB


Hallo, here are examples you need, I hope:

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;

Good luck !

Re:Storing TForm and/or its properties in a BLOB


Quote
In article <N.100596.154027.26@thelink> del...@iafrica.com (Me) writes:
>From: del...@iafrica.com (Me)
>Subject: Re: Storing TForm and/or its properties in a BLOB
>Date: Sat, 05 Oct 96 13:40:27 GMT
>On 05/10/1996 01:44, in message <5347nj$...@mtinsc01-mgt.ops.worldnet.att.net>,
>John M. Miano <mi...@worldnet.att.net> wrote:
>> Get a copy of "Secrets of Delphi 2.0"

>Is that all you can say? A VERY good tip *sarcastic look*.
>*begin-of-flame*
>We do not have all the possibilities here in South Africa. The stuff has to be
>imported. If the importer feels there is not enough market they simply wont
>import the book. So if you don't mind, please provide a HELPFUL hint (Do you
>think I wouldn't buy the book if I had the chance?).
>*end-of-flame*
>Thank you
>Stefan
>P.S. I apologise for any discomforts caused.

try this

procedure TReportDesigner.BtnSaveClick(Sender: TObject);
var
  RepStream, SelfStream: TBlobStream;
  nstr : string;

begin
   nstr := EditRepName.text;
      if null_test(nstr) then begin
      showmessage('Report Must have a name !');
      TabbedNotebook1.pageindex := definepage;
      EditRepName.setfocus;
      exit;
   end;
   With TableSelfSave do begin
     open;
     setkey;
     TableSelfSaveRepName.asstring :=  nstr;
     if gotokey then begin
        showmessage('Existing Report Named'+nstr);
        TabbedNotebook1.pageindex := definepage;
        EditRepName.setfocus;
        exit;
     end
     else begin
        append;
     end;
     TableSelfSaveRepName.asstring :=  nstr;
     TableSelfSaveReportType.asinteger := RGReportFrom.itemindex;
     TableSelfSaveReportDestination.asinteger := RGDestination.itemindex;
     TableSelfSaveDateDesigned.asDatetime := now;
     TableSelfSaveOwnData.Transliterate := false;
     TableSelfSaveReport.Transliterate := false;
     SelfStream := TBlobStream.Create(TableSelfSaveOwnData, bmWrite);
     RepStream := TBlobStream.Create(TableSelfSaveReport, bmWrite);
try
    SelfStream.writecomponent(dumcomponent);
    RepStream.writecomponent(DesignerReport);
    post;
finally
    SelfStream.Free;
    RepStream.Free;
    TableSelfSave.CLOSE;
end;
end;
end;

HTH

Boris Ingram, Cyborg Software
boris...@iafrica.com
100076.3...@compuserve.com
http://www.pcb.co.za/users/borising/cyborg.htm

Re:Storing TForm and/or its properties in a BLOB


Hi Stefan,

I noticed you got some replies (*snicker*)

We did something similar a while ago, and here are some hints:
1) Make sure that the application contains a form that has all the
components on it you plan to store/retrieve. Delphi's smart linker tends to
remove all code for stuff it thinks it won't need.
2) Are you really sure you want to do this? We weren't too happy with
results. It works, but if any component changes, your in a bit of a jam.
3) If you are sure, I would suggest not to simply dump the form in binary
format, but to process the components separately, and parsing it when
loading it back. This would protect you from any nastiness in component
changes in the future.

* Start of mini flame *
There seems to something horribly wrong with your News Browser. All your
messages seem to be from a person called 'Me', even though your work is
signed as Stefan. Please correct this problem.

Regards,

  Willo

Re:Storing TForm and/or its properties in a BLOB


Quote
Me wrote:

> On 05/10/1996 01:44, in message <5347nj$...@mtinsc01-mgt.ops.worldnet.att.net>,
> John M. Miano <mi...@worldnet.att.net> wrote:

> > Get a copy of "Secrets of Delphi 2.0"

> Is that all you can say? A VERY good tip *sarcastic look*.

> *begin-of-flame*
> We do not have all the possibilities here in South Africa. The stuff has to be
> imported. If the importer feels there is not enough market they simply wont
> import the book. So if you don't mind, please provide a HELPFUL hint (Do you
> think I wouldn't buy the book if I had the chance?).
> *end-of-flame*

http://www.bookpool.com
http://www.amazon.com

Or, for Ray's book, check out his page at http://www.tempest-sw.com/.

Most publishers also sell their own books at their homepages.

M.

--
Ettertraktet kaffe, er det ekstra god kaffe?

mailto:martin.lars...@delfi-data.msmail.telemax.no
http://www.delfidata.no/users/~martin

Re:Storing TForm and/or its properties in a BLOB


Quote
Willo wrote:

> Hi Stefan,

> I noticed you got some replies (*snicker*)

> We did something similar a while ago, and here are some hints:
> 1) Make sure that the application contains a form that has all the
> components on it you plan to store/retrieve. Delphi's smart linker tends to
> remove all code for stuff it thinks it won't need.

Use RegisterClass in th initialization section

 _
| | |  _     _        http://www.stud.ntnu.no/~olavb/
|_| |_|_|_|_|                     mailto:Ol...@dds.nl
Eyecom Images, Amsterdam

Other Threads