Solved

Cut&Copy from RichEdit add linefeeds :-(

Posted on 1997-11-23
14
407 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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
 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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