Page 1 of 1

Funny characters when copying between TRichViewEdit components

Posted: Wed Jul 08, 2020 1:33 pm
by johannes.burger
We have a generic copy-and-paste mechanism in our system. It has been working great except when we copy and paste between 2 TRichViewEdit components.
If I copy (Ctrl+C) from any source, such as MS-Word, Notepad, web page, etc. and paste (Ctrl+V) into a TRichViewEdit component, everything works 100%. The same goes for the other way - if I copy from a TRichViewEdit component into MS-Word or Notepad, everything also works great.
The problem only occurs when I copy-and-paste between 2 TRichViewEdit components. It does copy the original text but it adds a bunch of funny characters to the end. E.g.
Copy Source: Sore Back
Pate Destination: Sore Back??orrection

We did implement a workaround but I would prefer that our generic copy-and-paste works everywhere.

Our generic paste function:
procedure TfrmMain.act02EditPasteExecute(Sender : TObject);
begin
if Assigned(FFocusControl) then
SendMessage(FFocusControl.Handle , WM_PASTE , 0 , 0);
end;

A workaround (that we do not like):
procedure TfrmMain.act02EditPasteExecute(Sender : TObject);
begin
if Assigned(FFocusControl) then
begin
if FFocusControl is TRichViewEdit then
(FFocusControl as TRichViewEdit).InsertText(Clipboard.AsText)
else
SendMessage(FFocusControl.Handle , WM_PASTE , 0 , 0);
end;
end;

Please can you help with resolving this issue.
Many thanks,

Re: Funny characters when copying between TRichViewEdit components

Posted: Wed Jul 08, 2020 5:01 pm
by Sergey Tkachenko
Please tell me
1) TRichView version
2) Delphi version
3) Value of Options property of the source editor
4) Value of AcceptPasteFormats of the destination editor

Re: Funny characters when copying between TRichViewEdit components

Posted: Thu Jul 09, 2020 8:19 am
by johannes.burger
Here are the details:
1. v18.4
2. Delphi 2010
3. [rvoScrollToEnd,rvoShowPageBreaks,rvoAutoCopyUnicodeText,rvoAutoCopyRVF,rvoAutoCopyImage,rvoAutoCopyRTF,rvoFormatInvalidate,rvoDblClickSelectsWord,rvoRClickDeselects,rvoShowItemHints,rvoFastFormatting]
4. [rvddRVF,rvddRTF,rvddText,rvddUnicodeText,rvddBitmap,rvddMetafile,rvddFiles,rvddHTML]

Re: Funny characters when copying between TRichViewEdit components

Posted: Thu Jul 09, 2020 8:38 am
by Sergey Tkachenko
Very strange.
Can you give me step-by-step instructions how to reproduce it? May be with a simple sample project.

Re: Funny characters when copying between TRichViewEdit components

Posted: Thu Jul 09, 2020 11:03 am
by johannes.burger
Step-by-step instructions are fairly easy. We have a form with a TRichViewEdit component on. We can open multiple instances of the form. You can use the form to insert data into the DB, view data or edit data. We open an instance of the form in "edit" state and another instance in "insert" state. You then select data from the "edit" form and press ctrl+c, you go to the "insert" form and paste by using ctrl+v. Doing it like this adds the funny characters to the text on the "insert" form. If I paste the same data into Word or notepad, everything is fine and no funny characters appear.

I've tried to do a small sample project but we have so much functionality in base classes and templates that I was not able to do it.

Re: Funny characters when copying between TRichViewEdit components

Posted: Fri Jul 10, 2020 7:21 pm
by Sergey Tkachenko
Copying-pasting between two RichViewEdits must be in RVF format.
But I copy-pasted thousands times while testing the editor, and never seen a result like this.
Maybe you have some copy in OnCopy or OnPaste events?
Is it possible to reproduce it on TRichView demo projects?