trichview.com

trichview.support




Converting standard text to RVF


Return to index


Author

Message

sean mccall

Posted: 05/16/2003 0:08:01


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






Powered by ABC Amber Outlook Express Converter