Page 1 of 1

Struggling with clipboard copying

Posted: Thu Jun 23, 2011 12:41 pm
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

Posted: Thu Jun 23, 2011 1:19 pm
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.

Posted: Fri Jun 24, 2011 8:16 pm
by BennieC
I will email it to you

Posted: Sat Jun 25, 2011 7:49 am
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;

Posted: Sat Jun 25, 2011 3:30 pm
by BennieC
Thanks Sergey
You're a star!
Bennie