Page 1 of 1

Styles lost when streaming RVF between TRichViews

Posted: Sun May 10, 2009 6:15 pm
by hoby.smith
Hello, Sergey...

Sorry to bother you, but I think I am missing something really obvious. I am trying to copy the contents of a TRichView on one form to a TRichView that is on another form. For some reason, no matter what I do, the styles seem to be lost when I do so (underline, bold, bullets/numbering, etc).

Here is the code I am using to do so:

Code: Select all

var
  aMemStream : TMemoryStream;
begin
  aMemStream := TMemoryStream.Create;
  try
    aSourceRV.SaveRVFToStream(aMemStream, False);
    aMemStream.Position := 0;
    aTargetRV.LoadRVFFromStream(aMemStream);
    aTargetRV.Format;
  finally
    aMemStream.Free;
  end;
end;
Both TRichViews have a TRVStyle with default settings. I have tried calling DeleteUnusedStyles and other things before calling the above code. But, nothing seems to help.

I must be missing something really obvious, because I don't have a problem loading an RVF stream from a file or memory, just when doing this.

Any ideas or directions on what I am missing here?

Thanks...

Posted: Mon May 11, 2009 7:02 am
by Sergey Tkachenko
Make sure that rvfoSaveTextStyles, rvfoSaveParaStyles are in aSourceRV.RVFOptions.

Posted: Tue May 12, 2009 9:50 pm
by hoby.smith
Doh! That did it. :) I was thinking those were on by default, but maybe creating a TRichView at runtime doesn't set them by default? Oh well. That takes care of it. Thanks!

Posted: Wed May 13, 2009 4:03 pm
by Sergey Tkachenko
Yes, components created at runtime have different initial values of some properties. It is because of the backward compatibility.
While it is possible to change default values for new TRichViews placed on a form at design time (see http://trichview.com/help/idh_trichview ... itor_.html ), changing initial values of TRichViews created at runtime would affect existing projects.