Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to copy the Caption of a TLabel to a clipboard? 1

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
Im trying to copy the Caption of a TLabel to the clipboard, how would I achieve this? Any bits of code, hints or suggestions are welcome.

The reason I want to use an TLabel is because I dont want the users to be able to change its contents but I do want them to be able to copy it of there, I know I could use a read-only TEdit but I think that looks so dumb if people can select text they cant change.

This is what I have tried so far, on contextclick copy the caption of the label to an invisible TEdit and copy from there to the clipboard by MyEdit.CopyToClipboard; this doesn't seem to work when not visible.

Ive tried this (MyLabel as TEdit).CopyToClipboard;
(I know, but I'll try anything lol)

Thanx allot in advance,

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Code:
uses Clipbrd;

procedure TForm1.Label1DblClick(Sender: TObject);
begin
     Clipboard().AsText := Label1.Caption;
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top