The DragDrop event has different arguments for different objects:
Object |
See |
---|---|
ListBox, ListView, and Tab controls |
|
TreeView control |
|
Windows and other controls |
For information about the DataWindow control’s DragDrop event, see the DataWindow Reference or the online Help.
Occurs when the user drags an object onto the control and releases the mouse button to drop the object.
Event ID |
Objects |
---|---|
pbm_lbndragdrop |
ListBox |
pbm_lvndragdrop |
ListView |
pbm_tcndragdrop |
Tab |
Argument |
Description |
---|---|
source |
DragObject by value (a reference to the control being dragged) |
index |
Integer by value (the index of the target ListView item) |
Long. Return code choices (specify in a RETURN statement):
0 Continue processing
For ListView controls, see the example for BeginDrag.
This example inserts the dragged ListView item:
This.AddItem(ilvi_dragged_object)
This.Arrange( )
Occurs when the user drags an object onto the control and releases the mouse button to drop the object.
Event ID |
Objects |
---|---|
pbm_tvndragdrop |
TreeView |
Argument |
Description |
---|---|
source |
DragObject by value (a reference to the control being dragged) |
handle |
Long by value (the handle of the target TreeView item) |
Long. Return code choices (specify in a RETURN statement):
0 Continue processing
This example inserts the dragged object as a child of the TreeView item it is dropped upon:
TreeViewItem ltv_1
This.GetItem(handle, ltv_1)
This.SetDropHighlight(handle)
This.InsertItemFirst(handle, itvi_drag_object)
This.ExpandItem(handle)
This.SetRedraw(TRUE)
Occurs when the user drags an object onto the control and releases the mouse button to drop the object.
Event ID |
Objects |
---|---|
pbm_bndragdrop |
CheckBox, CommandButton, Graph, Picture, PictureHyperLink, PictureButton, RadioButton |
pbm_cbndragdrop |
DropDownListBox |
pbm_endragdrop |
SingleLineEdit, EditMask, MultiLineEdit, StaticText, StaticHyperLink |
pbm_prndragdrop |
HProgressBar, VProgressBar |
pbm_sbndragdrop |
HScrollBar, HTrackBar, VScrollBar, VTrackBar |
pbm_uondragdrop |
UserObject |
pbm_dragdrop |
Window |
Argument |
Description |
---|---|
source |
DragObject by value (a reference to the control being dragged) |
Long. Return code choices (specify in a RETURN statement):
0 Continue processing
When a control’s DragAuto property is true, a drag operation begins when the user presses a mouse button.
Example 1 In this example, the code in the DoubleClicked event for the DataWindow dw_orddetail starts a drag operation:
IF dw_orddetail.GetRow() > 0 THEN
dw_orddetail.Drag(Begin!)
This.DragIcon = "dragitem.ico"
END IF
Then, in the DragDrop event for a trashcan Picture control, this code deletes the row the user clicked and dragged from the DataWindow control:
long ll_currow
dwitemstatus ldwis_delrow
ll_currow = dw_orddetail.GetRow( )
// Save the row's status flag for later use
ldwis_delrow = dw_orddetail.GetItemStatus &
(ll_currow, 0, Primary!)
// Now, delete the current row from dw_orddetail
dw_orddetail.DeleteRow(0)
Example 2 This example for a trashcan Picture control’s DragDrop event checks whether the source of the drag operation is a DataWindow. If so, it asks the user whether to delete the current row in the source DataWindow:
DataWindow ldw_Source
Long ll_RowToDelete
Integer li_Choice
IF source.TypeOf() = DataWindow! THEN
ldw_Source = source
ll_RowToDelete = ldw_Source.GetRow()
IF ll_RowToDelete > 0 THEN
li_Choice = MessageBox("Delete", &
"Delete this row?", Question!, YesNo!, 2)
IF li_Choice = 1 THEN
ldw_Source.DeleteRow(ll_RowToDelete)
END IF
ELSE
Beep(1)
END IF
ELSE
Beep(1)
END IF