[BlueLeaf1336]>
PROGRAM>
Natural Born Junk>
Drag&Dropサンプル(ListBox版)
2002/11/12:作成
ドラッグアンドドロップのやり方ってほとんど定型なので、覚書き。
procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
index: integer;
begin
index := TListBox(Sender).ItemAtPos(Point(X, Y), True);
if index = -1 then
begin
Exit;
end else
begin
TListBox(Sender).BeginDrag(False, 5);
end;
end;
procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
var
index: integer;
begin
index := TListBox(Sender).ItemAtPos(Point(X, Y), True);
Accept := (index <> -1) and (TListBox(Sender) = TListBox(Source));
end;
procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
index: integer;
begin
index := TListBox(Sender).ItemAtPos(Point(X, Y), True);
TListBox(Sender).Items.Move(TListBox(Sender).ItemIndex, index);
end;