cobramania
asked on
CopyToClipboard
If I have var S: String;
How to copy string in S to Clipboard ?
Thanks
How to copy string in S to Clipboard ?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or in short,
just from the delphi help
get text from clipboard
procedure TForm1.Button1Click(Sender : TObject);
begin
if Clipboard.HasFormat(CF_TEX T) then
Edit1.Text := Clipboard.AsText
else
MessageDlg('There is no text on the Clipboard', mtInformation,
[mbOK],0);
end;
or
set text to clipboard
Clipboard.AsText := Edit1.Text;
more about asText
Represents the content of the clipboard as a string.
property AsText: string;
Description
Use the AsText property to place text in and retrieve text from the clipboard. The clipboard must contain a string or an exception occurs. To determine if the clipboard contains a string, pass CF_TEXT to the HasFormat method.
meikl ;-)
just from the delphi help
get text from clipboard
procedure TForm1.Button1Click(Sender
begin
if Clipboard.HasFormat(CF_TEX
Edit1.Text := Clipboard.AsText
else
MessageDlg('There is no text on the Clipboard', mtInformation,
[mbOK],0);
end;
or
set text to clipboard
Clipboard.AsText := Edit1.Text;
more about asText
Represents the content of the clipboard as a string.
property AsText: string;
Description
Use the AsText property to place text in and retrieve text from the clipboard. The clipboard must contain a string or an exception occurs. To determine if the clipboard contains a string, pass CF_TEXT to the HasFormat method.
meikl ;-)
ASKER
Thanks, it works fine, I just need the copy function :)
For kretzschmar, what I need is copy string from a variable to clipboard, not from TEdit. Thanks anyway :)
For kretzschmar, what I need is copy string from a variable to clipboard, not from TEdit. Thanks anyway :)
the edit was only a placeholder for any stringvar
just include into the uses clause