Solved

Cut&Copy from RichEdit add linefeeds :-(

Posted on 1997-11-23
14
429 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
Technology Partners: 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month3 days, 19 hours left to enroll

630 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