Tell me how to copy the contents of Memo1 components to the buffer? And how to insert this content when pressing another button in Memo2?

    3 answers 3

    Here is an article on working with clipboard from Delphi

    uses ...Clipbrd;\\ Подключили модуль procedure TForm1.Button1Click(Sender: TObject); begin ClipBoard:=TClipboard.Create;\\ Создали объект ClipBoard.SetTextBuf(memo1.lines.text);\\Скопировали в буфер обмена текст if ClipBoard.FormatCount=4 then memo2.lines.text:=ClipBoard.AsText;\\ проверили если в буфере текст то вставили его в memo2 ClipBoard.Clear;\\Очистили после себя буфер обмена ClipBoard.free; \\ удалили объект end; 
    • maybe of course I’m getting so insolent, but .. ClipBoard: = TClipboard.Create; \\ created an object (Left side cannot be assigned to) ClipBoard.SetTextBuf (memo1.lines.text); \\ copied text to the clipboard ( Undeclared identifier: 'StrToChr') if with the second error I still see chances to cope, then with the first..uva (I cry for help .. - Zein
    • one
      Of course impudent, that laziness was to read the article and turn on the brain? first TClipboard.Create; just without ClipBoard: = Second ClipBoard.SetTextBuf (memo1.Lines.GetText) instead of ClipBoard.SetTextBuf (memo1.Lines.Text) Well, of course, comments slash in the other direction, absolutely not want to think - SoftR
    • what comments slash in the other direction to me Delphi suggested) - Zein
    • thanks, everything turned out great) I will definitely read the article;) - Zein

    In a loop, line by line.

    • more details please how to address the buffer? and other trifles, as I don’t have any experience with working with a buffer .. - Zein
    • You are sure that the buffer is necessary. This is so without any buffer: int c = Memo1-> Lines-> Count; for (int i = 0; i <c; i ++) Memo2-> Lines-> Add (Memo1-> Lines-> Strings [i]); - BuilderC
    • Your C code, the person asked for Delphi - SoftR
    • on Delphi it will look something like this? <pre> for i = 0 to (and what's here?) do inc (i); Memo2.Lines.Add (Memo1.Lines.Strings [i]); </ pre> - Zein
    • one
      Not at all :) for i: = 0 to memo1.Lines.Count-1 do memo2.Lines.Add (memo1.Lines.Strings [i]); But this is not work through the buffer, but line-by-line copying from one memo to another - SoftR
     Memo.CopyToCliboard Memo.PasteFromClipboard 
    • This is what language ??? - SoftR
    • This is delphi)) - Alexey Lobanov
    • someone was zaminusovat, although it is quite working code if the module is connected Clipbrd - Zein