TSRichViewEdit doesn't save/load controls

General TRichView support forum. Please post your questions here
Post Reply
elGringo
Posts: 49
Joined: Thu Oct 08, 2015 7:01 pm

TSRichViewEdit doesn't save/load controls

Post by elGringo »

Having TSRichViewEdit. Inserting control like this

Code: Select all

SRichViewEdit.RichViewEdit.InsertControl('',scaleReportPanel,rvvaAbsMiddle);
updating DB like this

Code: Select all

...
         // blob

                 SRichViewEdit.RVHeader.SaveRVFToStream(msHeader,false);
                 SRichViewEdit.RichViewEdit.SaveRVFToStream(msBody,false);
                 SRichViewEdit.RVFooter.SaveRVFToStream(msFooter,false);

                TBlobField(FieldByName('blobContentHeader')).LoadFromStream(msHeader);
                TBlobField(FieldByName('blobContentBody')).LoadFromStream(msBody);
                TBlobField(FieldByName('blobContentFooter')).LoadFromStream(msFooter);

                if ApplyUpdates<>0 then raise Exception.Create(RowError.Message);
...
loading content like this...

Code: Select all

...
                TBlobfield(FieldByName('blobContentHeader')).SaveToStream(msHeader);
                msHeader.Position:=0;
                SRichViewEdit.RVHeader.LoadFromStream(msHeader,rvynaNo);
                SRichViewEdit.RVHeader.ReformatAll;

                TBlobfield(FieldByName('blobContentBody')).SaveToStream(msBody);
                msBody.Position:=0;
                SRichViewEdit.RichViewEdit.LoadFromStream(msBody,rvynaNo);
                SRichViewEdit.RichViewEdit.ReformatAll;

                TBlobfield(FieldByName('blobContentFooter')).SaveToStream(msFooter);
                msFooter.Position:=0;
                SRichViewEdit.RVFooter.LoadFromStream(msFooter,rvynaNo);
                SRichViewEdit.RVFooter.ReformatAll;

...
Text saved well - controls disappearing.... why?
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: TSRichViewEdit doesn't save/load controls

Post by Sergey Tkachenko »

Classes of all controls inserted in the editor must be registered.
Call one time, before the first loading:

Code: Select all

RegisterClasses([TEdit, TButton]);
(for all classes of used controls)
elGringo
Posts: 49
Joined: Thu Oct 08, 2015 7:01 pm

Re: TSRichViewEdit doesn't save/load controls

Post by elGringo »

Sorry for interrupting, not attentive today, just needed to register class...
RegisterClass(TScaleReportPanel);
elGringo
Posts: 49
Joined: Thu Oct 08, 2015 7:01 pm

Re: TSRichViewEdit doesn't save/load controls

Post by elGringo »

And else... is it normal approach to have 3 fields for header, body and footer? Or it could be just one which is pointed id DataField property of TDBSRichViewEdit
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: TSRichViewEdit doesn't save/load controls

Post by Sergey Tkachenko »

You do not 3 fields. SRichViewEdit.RichViewEdit.SaveRVFToStream saves the whole document, including header and footer.

Saving:

Code: Select all

SRichViewEdit.RichViewEdit.SaveRVFToStream(msBody,false);
TBlobField(FieldByName('blobContentBody')).LoadFromStream(msBody);
Loading:

Code: Select all

TBlobfield(FieldByName('blobContentBody')).SaveToStream(msBody);
msBody.Position:=0;
SRichViewEdit.RichViewEdit.LoadFromStream(msBody,rvynaNo);
SRichViewEdit.Format;
Please note that in the new version, there are not 2 but 6 headers and footers, stored in Subdocuments property. But all of them are saved and loaded by the code above.
Post Reply