Struggling with clipboard copying

General TRichView support forum. Please post your questions here
Post Reply
BennieC
Posts: 28
Joined: Sat Jun 18, 2011 7:00 pm

Struggling with clipboard copying

Post by BennieC »

Hi,
I struggle to copy data from one RichViewEdit to another.

procedure TfmPrjMain.bbTxferFromClick(Sender: TObject);
var
ARVComponent : TRichViewEdit;
begin
ARVComponent := RichViewEdit1;
if ARVComponent <> nil then
begin
myEdForm.RichViewEdit1.options := [rvoAutoCopyRVF];
myEdForm.RichViewEdit1.Format;
myEdForm.RichViewEdit1.SelectAll;
myEdForm.RichViewEdit1.CopyDef;
ARVComponent.PasteRVF;
ARVComponent.Format;
end;
end;

Could it be that I am using the trial still as my second RVE just stays with the default text and I don't get the data in.
I would like to know where I misunderstand the RVE operation.
Is there another way to transfer the content?

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

Post by Sergey Tkachenko »

This code should work (Format is not needed after PasteRVF, but it does not important).
Can you send me a sample project reproducing this problem? May be there is something wrong with property settings.
BennieC
Posts: 28
Joined: Sat Jun 18, 2011 7:00 pm

Post by BennieC »

I will email it to you
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Your code works correctly. But RichViewEdit1 must be associated with TRVStyle component.
Place a new TRVStyle component on TfmPrjMain, and assign it to RichViewEdit1.Style (in the Object Inspector).

PS: copying via the Clipboard is not a good idea, because the Clipboard should not be changed unless the user directly calls Copy or Cut command.
Use this code to copy from Src to Dst:

Code: Select all

procedure CopyDoc(Src, Dst: TCustomRichViewEdit);
var Stream: TMemoryStream;
begin
  Stream := TMemoryStream.Create;
  Src.SaveRVFToStream(Stream, False);
  Stream.Position := 0;
  Dst.LoadRVFFromStream(Stream);
  Stream.Free;
  Dst.Format;
end;
BennieC
Posts: 28
Joined: Sat Jun 18, 2011 7:00 pm

Post by BennieC »

Thanks Sergey
You're a star!
Bennie
Post Reply