RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TDragObject Class

TDragObject is a base class used for managing drag operations.

Pascal
TDragObject = class(TObject);
C++
class TDragObject : public TObject;

Use TDragObject as a base class when creating a custom drag object to manage drag-and-drop operations or drag-and-dock operations. If the drag operation is associated with a single control that is dragged, derive the custom drag object from TBaseDragControlObject instead. Create the custom drag object in the OnStartDrag event of the dragged control. Use the public IsDragObject function within a target's OnDragOver event when accepting a drag drop.

Note: TDragObject is not automatically freed at the end of a drag operation. To work with a drag object that is freed at the end of the drag operation, use TDragObjectEx instead.
In Applications that do not need to override the virtual methods of TDragObject, a drag object is created automatically to manage drag operations. 

TDragObject allows more flexible drag operation handling. Normally, the Source parameter of the OnDragOver and OnDragDrop events is the control that starts the drag operation. If multiple controls of differing kinds need to start a drag of the same kind of data (for example, a file name, text, or a dollar amount), the source would need support for each kind of control. A drag object allows the target to handle drag sources as a single class of object, because each source control creates the same kind of drag object in their OnStartDrag events. The OnDragOver and OnDragDrop event handlers can tell if the source is a drag object, as opposed to the control, by calling IsDragObject

Drag objects can be dragged between multiple .DLLs as well as inside the main .EXE. This is useful if you are not using packages but still want drag operations to function from forms implemented in .EXEs to forms implemented in .DLLs. 

 

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