unit draguni;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
ListBox1: TListBox;
ListBox2: TListBox;
procedure ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
procedure ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState;
var Accept: Boolean);
procedure ListBox2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState;
var Accept: Boolean);
procedure ListBox2DragDrop(Sender, Source: TObject; X, Y: Integer);
procedure ListBox2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button = mbLeft
then with Sender
as TListBox
do begin
if ItemAtPos (Point (x,y),true) >= 0
then
BeginDrag (false);
end;
end;
procedure TForm1.ListBox2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button = mbLeft
then with Sender
as TListBox
do begin
if ItemAtPos (Point (x,y),true) >= 0
then
BeginDrag (false);
end;
end;
procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState;
var Accept: Boolean);
begin
Accept := Source
is TListBox;
end;
procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if Source
is TListBox
then with ListBox1
do begin
Text := ListBox2.Items[ListBox2.ItemIndex];
ListBox1.AddItem(Text,source);
ListBox2.Items.Delete (ListBox1.ItemIndex);
end;
end;
procedure TForm1.ListBox2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState;
var Accept: Boolean);
begin
Accept := Source
is TListBox;
end;
procedure TForm1.ListBox2DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if Source
is TListBox
then with ListBox2
do begin
Text := ListBox1.Items[ListBox1.ItemIndex];
listbox2.AddItem(Text,source);
ListBox1.Items.Delete (ListBox2.ItemIndex);
end;
end;
end.