Solved

Cut&Copy from RichEdit add linefeeds :-(

Posted on 1997-11-23
14
394 Views
Last Modified: 2013-11-22
If i cut or copy some plaintext out of a TRichEdit using the clipboard standard hotkey (Shift-del, ctrl-c, ctrl-x) and paste it then to notepad, everything is ok.
But if i paste it to MS Outlook Express or some other special applications, at each line a linefeed is added.

I tried to write a message handler for the WM_CUT and WM_COPY message, but the Richedit don't send this messages if i using the standard hotkeys.

Can someone tell me why and how i can solve this?

Bye, Sascha
0
Comment
Question by:otti
  • 7
  • 2
  • 2
  • +3
14 Comments
 
LVL 1

Expert Comment

by:aluiken
ID: 1351593
Hi Sasha,

i can't tell you why but maybe i know the answer. (it's kind of hard because i am at my work and don't have delphi here so there may be some wrong syntaxes)

On the KeyDown event from the TRichEdit create a procedure in that procedure create a keyhandler eg something like

If Key = 'C' And Shift = 'Crtl' Then .......

Then copy the selected text to the clipboard i tought it was something like: RichEdit1.SelText.SaveToClipBoard;
(don't forget to include ClipBoard in your uses clause)

Best Regards,

Arijan
0
 

Author Comment

by:otti
ID: 1351594
Maybe the linefeeds are the {\par} in the richtext. Maybe you could use a Memo. Or do you need colors and formating in the text ?
0
 
LVL 1

Expert Comment

by:aluiken
ID: 1351595
Hi!

I use plaintext in RichEdit, no formating and colors or something.
I need TRichEdit because TMemo only can handle up to 64kB.

Bye, Sascha
0
 

Author Comment

by:otti
ID: 1351596
Adjusted points to 400
0
 

Author Comment

by:otti
ID: 1351597
If I understand, the problem is that there is a linefeed copied to the end of the text everytime you copy it from the Trichedit? Why not just deleting that linefeedcharacter? Or is that not possible?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1351598
Does it also appears when you set the PlainText property to true?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1351599
Hi!

I think that this are not real linefeeds, because if i paste the text in notepad everything is OK. Only when i paste in Outlook express the lines are broken by empty lines.

If i delete the last character of each line, a char of the text will be deleted.

The property "Plaintext" is set to true.

Bye, sascha
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:otti
ID: 1351600
Hi!

To say it clear: At each line a linefeed is added.

Here an example:

-------BEGIN--------------
This is the text in the
RichEdit. The text is loaded
from a file or is typed in
from the user.
------END----------------

If i cut it from RichEdit and paste to Outlook Express:

---------BEGIN----------------

This is the text in the

RichEdit. The text is loaded

from a file or is typed in

from the user.

---------END----------------------

Sascha
0
 

Author Comment

by:otti
ID: 1351601
Have you tried searching the strings for controlcaracters, they
do make the most weird things. Where some editors simply ignores them, others don't. Some obscure is definetly in it. use an hexeditor/viewer f.ex.
0
 
LVL 3

Expert Comment

by:williams2
ID: 1351602
Maybe something is wrong with your Outlook. Did you check the
options to avoid line feeds ?
0
 
LVL 2

Expert Comment

by:egono
ID: 1351603
Hi!

I viewed the saved file from Outlook with a hexviewer and there are really an extra CR and LF added.

A normal text looks:

This is a text in[CR LF]
Outlook.

And a pasted text looks:

This is a text in[CR LF CR LF]
Outlook.

If i save the file from my RichEdit and view it in HexEdit everything looks ok.

After some expermentation i think that the Clipboardformat is
not ok. If i cut a text out from notepad, Clipboard.format gives me "CF_TEXT", "CF_OEMTEXT" and "CF_LOCALE", but if i cut from TRichEdit i got many formats more like "CF_RICHEDIT" and some others.

Perhaps Outlook sees that the format in the Clipboard is not "CF_TEXT" and try to paste it as "CF_RICHEDIT".

But how to change Outlooks behavior??? Or better change TRichEdits behavior not to copy as "CF_RICHEDIT".

Sascha

0
 

Author Comment

by:otti
ID: 1351604
Hi Egono!

I looked hours in Outlook options for something that can be the
error, but i haven't found anything.

Did you found something??

Sascha
0
 

Author Comment

by:otti
ID: 1351605
I think I solved this annoying problem.
Try it:

uses clipbrd;

procedure TForm1.RichEdit1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
begin
      If (key = 67) and (ssCtrl in Shift) Then begin
            ClipBoard.SetTextBuf(PChar(RichEdit1.SelText));
            Edit1.Text := 'Passou';
      end;
end;

procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
begin
      If (key = 67) and (ssCtrl in Shift) Then
            key := 0; //Prevent the real CTRL C, just for                             optimazation resons
end;

0
 
LVL 4

Accepted Solution

by:
itamar earned 500 total points
ID: 1351606
Hi!

Great, this works!

Many thanks,

Sascha
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now