Solved

Put a String on the Clipboard

Posted on 1998-03-24
4
189 Views
Last Modified: 2010-04-06
In my program I have a string that I want to put on the clipboard, so I can paste it in another application (for example a word processor).  How do I do that?
0
Comment
Question by:TechStone
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 50 total points
ID: 1360817
Hi

If you have a string you can copy it to the clipboard as follows:
procedure TForm1.DoTheCopy;
var
  Clp: TClipBoard;
begin
  Clp := TClipBoard.Create;
  Clp.AsText := 'Hello';  // Your string goes here.
  Clp.Free;
end;

Also, if you have selected text in an edit control (e.g. TMemo) you can copy it by calling:
  MyMemo.CopyToClipboard;

Regards,
JB
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1360818
P.S.  Add ClipBrd to your uses clause in order to use TClipBoard.
0
 

Author Comment

by:TechStone
ID: 1360819
Thank you, that works perfectly!

0
 

Expert Comment

by:puzhikadu
ID: 1360820
procedure CopyButtonClick(Sender: TObject);
begin
   If ActiveControl is TMemo then TMemo(ActiveControl).CopyToClipboard;
   If ActiveControl is TDBMemo then TDBMemo(ActiveControl).CopyToClipboard;
   If ActiveControl is TEdit then TEdit(ActiveControl).CopyToClipboard;
   If ActiveControl is TDBedit then TDBedit(ActiveControl).CopyToClipboard;
end;

procedure PasteButtonClick(Sender: TObject);
begin
   If ActiveControl is TMemo then TMemo(ActiveControl).PasteFromClipboard;
   If ActiveControl is TDBMemo then TDBMemo(ActiveControl).PasteFromClipboard;
   If ActiveControl is TEdit then TEdit(ActiveControl).PasteFromClipboard;
   If ActiveControl is TDBedit then TDBedit(ActiveControl).PasteFromClipboard;
end;

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

930 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now