unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, System.ComponentModel, Borland.Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    ListBox2: TListBox;
    procedure ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormResize(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.nfm}

procedure TForm1.FormCreate(Sender: TObject);
var i :Integer;
begin
for i:=0 to 9 do
    begin
    ListBox1.Items.Add('Lista 1 : '+IntToStr(i));
    ListBox2.Items.Add('Lista 2 : '+IntToStr(i));
    end;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
ListBox1.Width:=ClientWidth div 2;
end;

procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
if (Button = mbLeft) then (Sender as TListBox).BeginDrag(false);
end;



procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
Accept:=false;
if (Source<>Sender) then Accept:=true;
end;



procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
   ItemPos :Integer;
   SenderLB,SourceLB :TListBox;
begin
SenderLB:=Sender as TListBox;
SourceLB:=Source as TListBox;

for ItemPos:=0 to SourceLB.Items.Count-1 do
if (SourceLB.Selected[ItemPos]) then
SenderLB.Items.Add(SourceLB.Items.Strings[ItemPos]);

for ItemPos:=SourceLB.Items.Count-1 downto 0 do
if (SourceLB.Selected[ItemPos]) then
SourceLB.Items.Delete(ItemPos);
end;

end.
