trichview.com

trichview.support




Re: Converting standard text to RVF


Return to index


Author

Message

sean mccall

Posted: 05/16/2003 15:11:02


Sergey,


I have solved the problem with the access violation. It had something to

do with the TActionList and TImageList being in a data module when the

word processing form was dynamically created. I moved the action list

and image list to the form itself and made the appropriate adjustments

to the .DFM and .PAS files. The only problem remaining is that the data

does not physically save to the field. I can see the changes in the

editing form's TDBRichEdit control after making changes in the word

processing form, but they do not get saved to the field. The original

message is appended to the end of this message for your convenience.

Note that the TStringStream has been changed to a TMemoryStream.



Sean


> Original Message:

>

> Hi,

>

> I am using the evaluation version of TRichView and am trying to create a

> simple word processor to edit the contents of a TBlobField.  I have a

> TDBRichEdit on a form (Edit Form) that displays the contents of the blob

> field which was populated from a simple text memo (TMemoField). On this

> form I have a button which opens a separate word processing form which

> is based on the TRichViewActions demo.

>

> I am able to load the word processing form with the data from the Edit

> Form and able to pass it back to the Edit Form successfully in a stream.

> I cannot get the streamed data to modify the field underlying the

> TdBRichEdit. To make matters worse, if I make a change to the data in

> the word processing form which results in an unsuccessful change to the

> TDBRichEdit in the EditForm, I get an access error while creating the

> word processing form in every subsequent call, even if it is from a new

> instance of the edit form. The word processor form comes up since this

> error is apparently trapped in the TRichView source code, but the

> TRichViewEdit on that form is in an unstable state with no font or font

> size selected.

>

> The OnClick method of the button on the Edit Form follows. Note that

> DFEncoded is a TDBRichView, DTLetter is the table, TWordProc is the

> renamed TRichViewActions demo. I used a TStringStream so I could easily

> confirm the stream's contents while debugging.

>

> procedure TFMLetter.BTWordProcClick(Sender: TObject);

> var

>   AStream: TStringStream;                       {stream to edit data}

> begin

>   AStream := TStringStream.Create('');          {use a string stream}

>   try

>     DFEncoded.SaveRVFToStream(AStream, False);  {save to stream}

>     if TWordProc.Execute(AStream) then begin    {modified?}

>       DTLetter.Edit;                            {put in edit mode}

>       AStream.Position := 0;                    {start of stream}

>       DFEncoded.LoadRVFFromStream(AStream);     {load from stream}

>       DFEncoded.Format;                         {reformat}

>     end; {if modified}

>   finally

>     AStream.Free;                               {release stream}

>   end; {try-finally}

> end; {procedure}

>

> The word processing form TWordProc is essentially the TRichViewActions

> demo renamed to TWordProc and with the following class method:

>

>

> class function TWordProc.Execute(AStream: TStream): Boolean;

> begin

>   with Create(Application) do begin

>     try

>       Editor.Clear;                             {clear editor}

>       AStream.Position := 0;                    {start of stream}

>       Editor.LoadRVFFromStream(AStream);

>       Editor.Format;                            {format the text}

>       ShowModal;                                {show modal}

>       Result := (ModalResult = mrOK);           {true if value changed}

>       if Result then begin                      {make changes?}

>         AStream.Position := 0;                  {start of stream}

>         Editor.SaveRVFToStream(AStream, False); {save back to stream}

>       end; {if changes made}

>     finally

>       Release;                                  {release form}

>     end; {try-finally}

>   end; {with the application}

> end; {procedure}

>

> The other changes:

>

> 1. The "alternate method" for creating the the form is used so that it

> starts with an empty document instead of trying to open the readme file.

> 2. The close query method no longer asks to save to a file.

> 3. The option to save tags as PChars has been turned off.

>

> Any ideas what I could be doing wrong here? What is the proper way to

> initialize a TCustomRichEdit so that it is ready to edit text or have it

> copied from some source other than a file.

>

> Thanks,

>

> Sean

>

>

> Sergey Tkachenko wrote:

>

>> First idea: do not use TStringStream. It does not work correctly with

>> binary

>> data.

>> Use TMemoryStream

>>

>>

>





Powered by ABC Amber Outlook Express Converter