We help IT Professionals succeed at work.

clipbrd

nod31
nod31 asked
on
i have a memo and would like to know how can i :-

 read contents of clipboard into it using a button
 write contents of memo to the clipboard
 clear the clipboard
Comment
Watch Question

Commented:
try adding clipbrd to your uses clause then:

memo1.text := clipBoard.AsText;
clipBoard.AsText := 'Hello World!';
clipBoard.AsText := '';

GL
Mike
Mohammed NasmanSoftware Developer
CERTIFIED EXPERT

Commented:
Hello

To copy text from memo to clipboard
  Memo1.CopyToClipboard;

to copy text from Clipboard to memo
  Memo1.PasteFromClipboard;

Commented:
Oh, I hadn't thought of that, though it would work just fine.  You'll only have to chek & ensure that there's text in the clipboard, something like this should work:

if clipBoard.hasFormat(CF_TEXT) then
 memo1.pasteFromClipBoard;

GL
Mike
Mohammed NasmanSoftware Developer
CERTIFIED EXPERT

Commented:
I forgot the third thing, if you want to clear the clipboard

uses  clipbrd ;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ClipBoard.Clear;
end;

Explore More ContentExplore courses, solutions, and other research materials related to this topic.