RAD Studio
ContentsIndex
PreviousUpNext
Ending a Drag Operation

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.

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

 

void __fastcall TFMForm::FileListBox1EndDrag(TObject *Sender, TObject *Target,   int X, int Y)
  if (Target)
    FileListBox1->Update();
};
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!