Hi,
die Startposition ist immer gleich der Dropposition bei einem Drag&Drop in einer Listbox.
Warum ? Das darf nämlich nicht sein....
Delphi-Quellcode:
procedure TfrmMain.lbListDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Source = lbList;
end;
procedure TfrmMain.lbListDragDrop(Sender, Source: TObject; X, Y: Integer);
var DropPosition : Integer;
StartPosition : Integer;
i : Integer;
DropPoint : TPoint;
temp : TAudioFile;
begin
DropPoint.X := X;
DropPoint.Y := Y;
with Source as TListBox do
begin
StartPosition := ItemAtPos(StartingPoint,True);
DropPosition := ItemAtPos(DropPoint,True);
temp := fFiles[startposition];
for i := startposition downto dropposition + 1 do
begin
fFiles[i] := fFiles[i-1];
end;
for i := startposition to dropposition - 1 do
begin
fFiles[i] := fFiles[i+1];
end;
fFiles[dropposition] := temp;
UpdateListBox;
end;
end;