Cut and paste

Hello,

I want to create a simple application like this :

It has a button.

If I click that button, then it will send a text to the clipboard system.

So, if I press CTRL-V, that text will be pasted to notepad for example.

Anyone know how to send text (multiple lines) to clipboard system ?

thanks
kapotAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
kretzschmarConnect With a Mentor Commented:
uses tclipboard;

...
begin
  Clipboard.SetTextBuf(PCHar('MyLongText'+#10+'SecondLine');
end;

just from head

meikl ;-)
0
 
kretzschmarCommented:
one ) missed on end
0
 
esoftbgCommented:
procedure TForm1.Button1Click(Sender: TObject);
begin
  if (Memo1.SelLength>0) then
    Memo1.CopyToClipboard;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Memo2.PasteFromClipboard;
end;
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Colin_DawsonConnect With a Mentor Commented:
you'd be better using #13#10 for the line  break.   #13 is a carriage return and #10 is a line feed.   Some programs will accept an either/or/or both combination, but there are some others that MUST have the pair.  Notepad itself isn't too fussy, but it's best to be complete.
0
 
kretzschmarCommented:
well, agreed, colin :-))
0
 
Colin_DawsonCommented:
Just call me "Mr. Pedantic" ;-)

Your suggestion answers the question so I think you should get the points.
0
 
esoftbgCommented:
I forgot to mention that it is a must to be into the uses-clause:

uses
  ...., Clipbrd
0
 
kretzschmarCommented:
hum, of course Clipbrd not tclipboard as i mentioned above (copy/paste error)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.