Funny characters when copying between TRichViewEdit components
Posted: Wed Jul 08, 2020 1:33 pm
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,
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,