I wouldn't suggest using the clipboard, as the user may want to use it 
him/herself.  The user could in fact copy something to the clipboard in 
another program at the same time as your program does, and end up with 
unusual results.

I suggest using the stream option.

----- Original Message ----- 
From: "Henry Bartlett" <[EMAIL PROTECTED]>
To: <delphi@elists.org>
Sent: Tuesday, March 20, 2007 8:19 AM
Subject: Re: copying one richedit to another


"Henry Bartlett"  wrote
> rePhraseSentence.Text := reSentence.Text;
>
> <UNTESTED>
Whoops! serves me right 8-)

I should have tested my code before jumping in.

Here are 2 methods that *do* work for me

Procedure StreamCopy (RE1, RE2: tRichEdit);
var MyStream: TMemoryStream;
begin
 MyStream := TMemoryStream.Create;
 Try
   RE1.Lines.SaveToStream (MyStream);
   MyStream.Seek(0, 0);
   RE2.Lines.LoadFromStream (MyStream);
   finally
     MyStream.Free;
   end;
end;

and

Procedure ClipBoardCopy (RE1, RE2: tRichEdit);
begin
  RE1.SelectAll;
  RE1.CopyToClipboard;
  RE2.Clear;
  RE2.PasteFromClipboard;
end;

HTH this time.

Henry Bartlett 

_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://www.elists.org/mailman/listinfo/delphi

Reply via email to