trichview.com

trichview.support




Re: Converting standard text to RVF


Return to index


Author

Message

sean mccall

Posted: 05/16/2003 18:30:58


Sergey,


Thanks. The value now saves to a field. Now I have a new problem

regarding styles which I have moved to a new thread.


Sean



Sergey Tkachenko wrote:

> Look at the help topic: "Using viewer-style methods in DBRichViewEdit"

> (Example 1 in the topic about TDBRichViewEdit)

>

> In brief, you need to call table.Edit before loading RVF in DBRichViewEdit,

> and dbrve.Change after.

> Then call table.Post (if you want to save data immediately) or dbrve.Format

> (if you want to save them later).

>

>

>

>>Sergey,

>>

>>By changing to TMemoryStream, the data was successfully changed in the

>>TDBRichEdit control, but not saved to the field. The problem still

>>remains that any subsequent calls to the word processing form still

>>result in an access error. Any other ideas? Since the problem is

>>happening in the TRichEdit source I cannot trace to the problem. I do

>>know that none of the fonts and sizes are been initialized when the form

>>comes up due to the exception in the constructor. I also know that the

>>error is trapped in the source since only the debugger's copy of the

>>exception comes up.

>>

>>Thanks,

>>

>>Sean

>>

>>

>>Original Messahge:

>>

>>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