
04.05.2009, 16:30
|
Модератор
|
|
Регистрация: 17.04.2008
Сообщения: 8,096
Версия Delphi: 7, XE3, 10.2
Репутация: 49089
|
|
Из моего проекта.
Код:
procedure TPLOrderForm.ListBox1DragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
procedure DrawLn(FromX, ToX, Y : Integer);
begin
ListBox1.Canvas.MoveTo(FromX,Y);
ListBox1.Canvas.LineTo(ToX,Y);
end;
var
P : TPoint;
R : TRect;
Idx : Integer;
begin
P.x := X;
P.y := Y;
Idx := ListBox1.ItemAtPos(P,False);
If Idx = DrwIdx Then Exit;
If DrwIdx > -1 Then
Begin
R := ListBox1.ItemRect(DrwIdx);
ListBox1.Canvas.Pen.Color := ListBox1.Color;
If DrwIdx < ListBox1.ItemIndex
Then DrawLn(R.Left,R.Right,R.Top)
Else DrawLn(R.Left,R.Right,R.Bottom);
End;
R := ListBox1.ItemRect(Idx);
ListBox1.Canvas.Pen.Color := clHighlight;
If Idx < ListBox1.ItemIndex
Then DrawLn(R.Left,R.Right,R.Top)
Else DrawLn(R.Left,R.Right,R.Bottom);
DrwIdx := Idx;
Accept := Source Is TListBox;
end;
procedure TPLOrderForm.ListBox1DragDrop(Sender, Source: TObject; X,
Y: Integer);
var
P : TPoint;
Idx : Integer;
begin
P.x := X;
P.y := Y;
Idx := ListBox1.ItemAtPos(P,False);
If Idx >= ListBox1.Items.Count-1 Then
Idx := ListBox1.Items.Count-1;
ListBox1.Items.BeginUpdate;
SwapPics(stTo, Idx);
ListBox1.Items.EndUpdate;
UpdateButtons;
end;
|