RAD Studio |  |

Ending a Drag Operation
See Also
Collapse All

A drag operation ends when the item is either successfully dropped or released over a control that cannot accept it. At this point an end-drag event is sent to the control from which the drag was initiated. To enable a control to respond when items have been dragged from it, attach an event handler to the control's OnEndDrag event.

The most important parameter in an OnEndDrag event is called Target, which indicates which control, if any, accepts the drop. If Target is nil, it means no control accepts the dragged item. The OnEndDrag event also includes the coordinates on the receiving control.

In the following VCL example, a file list box handles an end-drag event by refreshing its file list.

Copy Code

    procedure TFMForm.FileListBox1EndDrag(Sender, Target: TObject; X, Y: Integer);
    begin
      if Target <> nil then FileListBox1.Update;
    end;

Copy Code

    void __fastcall TFMForm::FileListBox1EndDrag(TObject *Sender, TObject *Target,   int X, int Y)
      if (Target)
        FileListBox1->Update();
    };

See Also

TWinControl

Implementing Drag and Drop in Controls

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!