TRichviewEdit to TRichView

General TRichView support forum. Please post your questions here
Post Reply
ChristopheA
Posts: 7
Joined: Mon Jan 22, 2007 5:25 pm

TRichviewEdit to TRichView

Post by ChristopheA »

Hi there,

Is it possible to transfer part of an RTF formated text of a RichViewEdit to a RichViewEdit, if yes how?

thanks

ChristopheA
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, it's possible.
You can save this part in stream as RVF, then load it in another RichViewEdit.

For example, this code loads the selected fragment of RichViewEdit1 to RichViewEdit2:

Code: Select all

var Stream: TMemoryStream;

Stream := TMemoryStream.Create;
RichViewEdit1.SaveRVFToStream(Stream, True);
Stream.Position := 0;
RichViewEdit2.LoadRVFFromStream(Stream);
Stream.Free;
RichViewEdit2.Format;
To copy the whole document, change the last parameter of SaveRVFToStream to False.

This code inserts the selected fragment of RichViewEdit1 in RichViewEdit2, in the caret position:

Code: Select all

var Stream: TMemoryStream;

Stream := TMemoryStream.Create;
RichViewEdit1.SaveRVFToStream(Stream, True);
Stream.Position := 0;
RichViewEdit2.InsertRVFFromStreamEd(Stream);
Stream.Free;
Post Reply