9.2.2 Receive drag items
Whether a control can receive a dragged item is determined by the control's OnDragOver event. In Tabset drag, the main point is to use the location of the mouse to judge.
Procedure Tform1.tabset1dragover (Sender, Source:tobject; X, Y:integer;
State:tdragstate; var accept:boolean);
Var
Droppos:integer;
Begin
If Source = TabSet1 Then
Begin
Droppos: = Tabset1.itematpos (Point (X, Y));
Accept: = (Droppos >-1) and (Droppos <> tabset1.tabindex) and
(Droppos < TabSet1.Tabs.Count);
End
Else
Accept: = False;
End
9.2.3 Drop Drag Item
When the OnDragOver event handler returns a accept of true and the project is dropped, the Ondragdrop event processing completes the drag drop response. In the Tabset drag-and-drop instance, the position of the label is changed.
Procedure Tform1.tabset1dragdrop (Sender, Source:tobject; X, Y:integer);
Var
Oldpos:integer;
Newpos:integer;
Begin
If Source = TabSet1 Then
Begin
Oldpos: = Tabset1.tabindex;
Newpos: = Tabset1.itematpos (Point (X, Y));
if (Newpos >-1) and (Newpos <> oldpos) Then
TabSet1.Tabs.Move (Oldpos, Newpos);
End
End
9.2.4 End Drag operation
There are two ways to end a drag operation: either the user releases the mouse button or the program uses the EndDrag method to forcibly abort the drag. There are two consequences of ending a drag operation: dropping is accepted or put down is ignored.
When the drag operation ends, the source control receives a message responding to the drag end event Onenddrag.