?
Solved

Put a String on the Clipboard

Posted on 1998-03-24
4
Medium Priority
?
198 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
[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
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
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: …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

771 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