Professional Documents
Culture Documents
Category: VCL
uses
Clipbrd;
GetMem(Buffer, BufferSize);
Ptr := Buffer;
Count := 0;
for I := 0 to ListBox.Items.Count - 1 do
begin
Line := ListBox.Items.strings[I];
if not CopyAll and ListBox.MultiSelect and (not ListBox.Selected[I]) then
Continue;
{ Check buffer overflow }
Count := Count + Length(Line) + 3;
if Count = BufferSize then
Break;
{ Append to buffer }
Move(Line[1], Ptr^, Length(Line));
Ptr := Ptr + Length(Line);
Ptr[0] := #13;
Ptr[1] := #10;
Ptr := Ptr + 2;
end;
Ptr[0] := #0;
ClipBoard.SetTextBuf(Buffer);
FreeMem(Buffer, BufferSize);
end;
Listbox.Items.Text := Clipboard.AsText;
end;
//Copy all items from Listbox1 to the clipboard
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBoxToClipboard(ListBox1, 1024, True);
end;
printed from
www.swissdelphicenter.ch
developers knowledge base