Page 1 of 1

Copy/paste without using the clipboard

Posted: Fri Mar 02, 2007 1:41 pm
by martindholmes
Hi there,

I need to move some data from one TRichViewEdit to another -- actually, I'm inserting the entire contents of one TRVE into the cursor position of the other. The simplest way to do this would be using copy/paste via the clipboard, but I don't want to do that because that will replace the previous contents of the clipboard without the user's permission.

Does anyone have any suggestions for moving data between two TRichViewEdits without using the clipboard?

All help appreciated,
Martin

Posted: Sat Mar 03, 2007 4:26 am
by shmp
If I am not mistaken, you can insert file from stream. Age have blurred my memory :(

Henry

Posted: Sat Mar 03, 2007 5:48 am
by mamouri
I think you could use this:
var
AStream: TMemoryStream;
begin
AStream := TMemoryStream.Create;
RichViewEdit1.SaveRVFToStream(AStream, True); // Copy the Selection into Stream
AStream.Position:=0;
RichViewEdit2.InsertRVFFromStream(AStream);
RichViewEdit2.Format;
end;
I type the code in editor. may be it need some changes in method names

Posted: Sat Mar 03, 2007 8:32 pm
by Sergey Tkachenko
If you need to copy the entire RichViewEdit1, call SaveRVFToStream with the last parameter = False.
To insert in the position of caret, use InsertRVFFromStreamEd. Do not call Format. Format is necessary after LoadRVFFromStream or InsertRVFFromStream, but not needed after InsertRVFFromStreamEd.

Posted: Sun Mar 04, 2007 12:29 am
by martindholmes
That's just what I need. Many thanks!

Cheers,
Martin