Link to home
Start Free TrialLog in
Avatar of cobramania
cobramania

asked on

CopyToClipboard

If I have var S: String;
How to copy string in S to Clipboard ?

Thanks
Avatar of kretzschmar
kretzschmar
Flag of Germany image

there is a clipbrd-unit,
just include into the uses clause
ASKER CERTIFIED SOLUTION
Avatar of OryxConLara
OryxConLara

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or in short,

just from the delphi help
get text from clipboard

procedure TForm1.Button1Click(Sender: TObject);
begin
if Clipboard.HasFormat(CF_TEXT) 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 ;-)
Avatar of cobramania
cobramania

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 :)
the edit was only a placeholder for any stringvar