[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Controls' (#lcl)

# TDragObject

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Base class for managing drag operations and feedback.

## Declaration

Source position: controls.pp line 349

`type TDragObject = class`
`protected`
`procedure EndDrag(); virtual;` |  | Called when a dragging operation ends.
`function GetDragImages; virtual;` |  | Returns a list of images for dragging.
`function GetDragCursor(); virtual;` |  | Returns the dragging cursor type.
`public`
`constructor Create(); virtual;` |  | Remembers the dragged control.
`constructor AutoCreate();` |  | Special constructor, enforcing the destruction of the object at the end of the dragging operation.
`procedure HideDragImage; virtual;` |  | Hides the drag image
`procedure ShowDragImage; virtual;` |  | Shows the drag image
`property AlwaysShowDragImages: Boolean; [rw]` |  | Should the image of dragged objects always be shown?
`property AutoCreated: Boolean; [r]` |  | Was the drag object created automatically?
`property AutoFree: Boolean; [r]` |  | Indicates whether the object shall be destroyed at the end of the dragging operation.
`property Control: TControl; [rw]` |  | The control that is dragged (source).
`property DragPos: TPoint; [rw]` |  | Mouse position in screen coordinates.
`property DragTarget: TControl; [rw]` |  | The control to which the current object is dragged (target).
`property DragTargetPos: TPoint; [rw]` |  | Mouse position in client coordinates of the DragTarget (site)
`property Dropped: Boolean; [r]` |  | Indicates whether the drag object has been dropped yet.
`end;`

## Inheritance

`TDragObject` |  | Base class for managing drag operations and feedback.
`TObject`

## Description

Every dragging operation has an associated DragObject, holding references to the source and target controls, and other parameters for the customization of the visual user feedback.

A default DragObject is created automatically when a dragging operation starts, and is destroyed when the operation has ended, so that you must not take special care on it. But an application can provide a customized DragObject in the TControl.OnStartDrag or TControl.OnStartDock handlers of the source control (being dragged).

TDragObject is the ancestor of an whole tree of dragging objects, with the main branches supporting either drag-drop or dock-drop operations. The type of the operation is determined from the TControl.DragKind property of the source control. In contrast to the Delphi implementation, Lazarus has moved a couple of methods into the drag performers, so that these are no more available for customization.

A Lazarus DragObject mainly supplies the cursor and images, used in visual user feedback. Drag-drop operations typically signal acceptance of an possible drop by variations of the mouse cursor, and optionally can attach to it shapes of the dragged object(s). Dock-drop operations instead show a docking rectangle, that snaps to possible target locations when the mouse moves over docksites.

[entire review DoDi 2010-02-16]

## See also

TDragControlObject |  | A drag object for dragging a control.
TDragDockObject |  |

The latest version of this document can be found at lazarus-ccr.sourceforge.net .