Summary

VLF Windows Application Development

Summary

VFW112 – Drag and Drop between Components

Important Observations

  • The default value of the DragStyle property is none. This means that the component will NOT support the initiation of a drag operation.
  • The StartDrag event occurs when the mouse button is pressed over a component and the mouse is moved. It is typically used to store away the data being dragged. As such, it might not be required when the information is dropped in the same form.
  • The DragOver event occurs when a Drag and Drop operation is in progress. You would decide whether to accept the drop operation during the DragOver event.
  • The DragDrop event occurs when the mouse button is released. During this event you would normally populate the target with the dragged data.
  • At the end of the DragDrop event the EndDrag occurs. It is a notification to the source that the Drag has finished. The routine would typically contain code which is related to the source component. For example, set DragResult to ACCPETED and delete selected entries from the DRAG_FROM list.

Tips & Techniques

  • Use a payload object as a temporary "storage" area when the data being dragged is not available in the component where it is to be dropped.

What I Should Know

  • How to Drag and Drop multiple items between two controls in different forms.
  • How to use the EndDrag routine.
  • How to use the DragResult property.
  • How to copy or move items using drag and drop.