Solved

Cut&Copy from RichEdit add linefeeds :-(

Posted on 1997-11-23
14
421 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
QRReport  TQrmemo vertical stretching 1 67
SUM 2 INTEGER ARRAYS INTO 1 10 118
enhance the following code 3 54
DBCtrlGrid, Delphi, Scroll 7 35
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

751 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