Page 1 of 1

Copy from TRichViewEdit to TRichViewEdit at runtime

Posted: Mon Mar 09, 2009 7:25 pm
by Prometeus
Hello,



I am having trouble to do a simple thing, I guess. If I use two 'TRichViewEdit' components created at design time the code below works great for copying from one to another (appending the 'source' to 'dest'). The problem is that I need create a document from scratch using two 'TRichViewEdit' components created at runtime. In this situation the code below doesn't works, i.e., although 'RVFFromStream' returns true it doesn't copy anything. What should I set for these runtime created components in order to do things working as expected?

-----

Code: Select all

function RVCopy(RVSource, RVDest : TCustomRichView) : Boolean;

var StreamTrab : TMemoryStream;

begin { *** RVCopy *** }
  StreamTrab := TMemoryStream.Create;
  try
    try
      if RVSource.SaveRVFToStream(StreamTrab,false) then
        begin
          StreamTrab.Position := 0;
          Result := RVDest.InsertRVFFromStream(StreamTrab,RVDest.ItemCount);
          RVDest.FormatTail;
        end
      else
        Result := false;
    except
      Result := false;
    end;
  finally
    StreamTrab.Free;
  end;
end; { *** RVCopy *** }
-----

Thanks for any help as I'm trying figuring this out for 10 days but to no avail.

Posted: Tue Mar 10, 2009 12:24 pm
by Sergey Tkachenko
Components created at runtime have different initial values of some properties.
Include rvfoSaveTextStyles and rvfoSaveParaStyles in RVFOptions of source TRichViews.

Posted: Wed Mar 11, 2009 6:43 pm
by Prometeus
Hello,



Thanks Sergey! It worked!