//--------------------------------------------------------------------------- bool __fastcall TextFromClipboard(UnicodeString & Text) { const wchar_t * AText = NULL; HANDLE Handle = OpenTextFromClipboard(AText); bool Result = (Handle != NULL); if (Result) { Text = AText; CloseTextFromClipboard(Handle); } return Result; }
//--------------------------------------------------------------------------- void __fastcall TRichEdit20::WMPaste() { // override default pasting to prevent inserting formatted text (RTF). const wchar_t * Text = NULL; HANDLE Handle = OpenTextFromClipboard(Text); if (Handle != NULL) { try { // replacement for EM_PASTESPECIAL, // which ignores trailing line end for some reason Perform(EM_REPLACESEL, true, reinterpret_cast<int>(Text)); } __finally { CloseTextFromClipboard(Handle); } } }