You'll need to do the paste manually ensuring that the formatting is ignored.
if Clipboard.HasFormat(CF_TEXT) then
RichEdit.SelText := Clipboard.AsText;
Run this code from a message handler for WM_PASTE
.
I currently do not know how to intercept the CTRL+V keypress and replace it with this code. The WM_PASTE
message is not sent to rich edit controls.
As Cody suggests in the comment, one solution is as follows:
- Make sure that all the text in the edit control is marked as protected.
- Subclass
TRichEdit
and override CNNotify
.
- Handle the
EN_PROTECTED
message, and if msg=WM_PASTE
then use the paste as text code above and return 1 from the message handler to indicate that the requested operation (a rich paste) is rejected.