paste text from clipboard sample please lazarus / 31-LCL ---------------------------------------------------------------------- Martin V · 2010-05-15 08:34 Hello, copying to clipboard works already fine, but I did not managed to simply paste text from clipboard into buffer / ansistring. I tried Clipboard.SupportedFormats and it was empty. I assume it is more simple that I mean. Please write some lines of sample code. I even compared my code with the synedit code, nothing helps. I tried:     Clipboard.Open;     ClipboardStream := tMemorystream.Create;     Clipboard.GetFormat (cf_text, ClipboardStream); and then     ClipboardStream.Write (Zero, 1);     result := pointer (ClipboardStream.Memory); alternate code     result := Pointer (Clipboard.AsText); The code should fit for all platforms. Thank you for any hint. ---------------------------------------------------------------------- theo · 2010-05-15 10:02 This should be enough: Code: [Select]uses Clipbrd; procedure TForm1.Button1Click(Sender: TObject); begin    Memo1.text:=Clipboard.AsText; end; ---------------------------------------------------------------------- Martin V · 2010-05-16 19:05 Theo, thanks for this simple hint. Clipboard.AsText alone works fine indeed. In clipbrd.inc tClipboard.GetAsText I could see how it works and the following code also works fine and I can change the format type of the clipboard. Code: [Select]    ClipboardStream := tMemorystream.Create;     if Clipboard.GetFormat (PredefinedClipboardFormat(pcfText), ClipboardStream) then begin       ClipboardStream.Write (Zero, 1); {adding terminating #0}       result := pointer (ClipboardStream.Memory);     end     else begin       result := nil;     end;     ClipboardStream.Free; Clipboard.Open / Clipboard.Close let the functionality fail. ---------------------------------------------------------------------- Bart · 2010-05-17 05:33 Many controls have methods called PasteFromClipBoard, CopyToClipBoard and CutToClipBoard. They will do the job for you, so you do not have to mess with the underlying code, to change the format of the clipboard. Bart