To view a printable version of this article in a PDF viewer,
click here for PDF
.
This artilce describes Object Linking and Embedding (OLE) drag and drop in FarPoint controls. After a general overview of OLE drag and drop and a comparsion between automatic and manual drag and drop, this article provides detailed information on how manual drag-and-drop operations work.
While most of the article focuses on FarPoint's fpSpread ActiveX® control, much of the information applies to all of FarPoint's controls that support OLE drag and drop. For information on a specific FarPoint control, see the documentation for that control.
OLE drag and drop allows the user to drag data (such as text or graphics) from one control or application to another control or application. For example, the user could select and drag text from Microsoft Word® and drop the text into an edit cell in FarPoint's fpSpread ActiveX control.
The object from which data is dragged is the
source
. The object into which the data is dropped is the
target
. You can use properties, events, and methods to control and respond to actions that affect both the source and the target. The
fpDataObject object
is a container for data being transferred from a source to a target in an OLE drag-and-drop operation. This object is called in the Spread controls' OLE drag-and-drop events.
Automatic Versus Manual Drag and Drop
OLE drag-and-drop operations can be either automatic or manual.
If a control supports
automatic
drag-and-drop operations, you do not need to write code to respond to any OLE drag-and-drop events. You only need to set the control's
OLEDragMode
property,
OLEDropMode
property, or both, to Automatic. If you choose, though, you can customize the drag-and-drop operation by setting the
OLEDragMode
property,
OLEDropMode
property, or both, to Manual and using the available events and methods.
If a control supports
manual
drag-and-drop operations, you must write code in the OLE drag-and-drop events to define what happens during the drag-and-drop operation. With manual drag-and-drop operations, you can
- Have greater control over the drag-and-drop process
- Provide feedback during drag-and-drop operations
- Specify which data formats are allowed
- Specify which drop effects are allowed
The Spread ActiveX controls support manual OLE drag-and-drop operations. Because the Spread controls support manual drag-and-drop operation, these controls can act as the source or target object.
Back to
the top
.
Properties, Methods, and Events Associated with a Manual OLE Drag-and-Drop Operations
The following table summarizes what events occur, what properties you set, and what methods you call in terms of the source control, the target control, and the fpDataObject object for each step of a manual OLE drag-and-drop operation. For more detailed information about what can occur during each step, see
How a Typical Manual Drag-and-Drop Operation Works
. For a flowchart that outlines the drag-and-drop operation, see
Manual OLE Drag-and-Drop Operation Flowchart
.
|
User action
|
Source control
|
Target control
|
fpDataObject object
|
What happens
|
| 1. Select data
|
|
|
|
Data is selected in the source.
|
| 2. Start drag
|
Mouse events
OLEDrag
method
OLEStartDrag
event
|
|
SetData
method
|
|
| 3. Drag source data over target
|
OLEGiveFeedback
event
|
OLEDropMode
property
OLEDragOver
event
|
GetFormat
method
|
|
| 4. Drop data on target
|
OLESetData
event
OLECompleteDrag
event
|
OLEDragDrop
event
|
GetFormat
method
SetData
method
GetData
method
|
Data is copied or moved to target. If move, data is deleted from the source.
|
Back to
the top
.
How a Typical Manual Drag-and-Drop Operation Works
The following table lists the steps involved in a typical manual OLE drag-and-drop operation and what happens and what to do in terms of the source and target control properties, events, and methods. For a more detailed flowchart showing this process and code examples, see
Manual OLE Drag-and-Drop Operation Flowchart
.
|
User action
|
What happens/What to do
|
1. Select data
|
Data to be copied or moved is selected.
|
2. Start drag
|
MouseDown
and
MouseMove
events occur.
In either mouse event, call the
OLEDrag
method (S). This manually starts the drag operation and fires the
OLEStartDrag
event (S).
In the
OLEStartDrag
event(S),
- Set the
AllowedEffects
parameter (None, Copy, Move, Scroll)
|