Solved

Put a String on the Clipboard

Posted on 1998-03-24
4
194 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: how to implement a User Shortcut mapper? 1 137
creating threads in delphi 1 163
Create a path if not exists 7 108
Delphi android app hide keyboard 3 46
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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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