Solved

Put a String on the Clipboard

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

9 Experts available now in Live!

Get 1:1 Help Now