Copy from TRichViewEdit to TRichViewEdit at runtime

General TRichView support forum. Please post your questions here
Post Reply
Prometeus
Posts: 16
Joined: Tue Jan 20, 2009 1:58 pm

Copy from TRichViewEdit to TRichViewEdit at runtime

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Components created at runtime have different initial values of some properties.
Include rvfoSaveTextStyles and rvfoSaveParaStyles in RVFOptions of source TRichViews.
Prometeus
Posts: 16
Joined: Tue Jan 20, 2009 1:58 pm

Post by Prometeus »

Hello,



Thanks Sergey! It worked!
Post Reply