DragDrop

The DragDrop event has different arguments for different objects:

Object

See

ListBox, PictureListBox, ListView, and Tab controls

Syntax 1

TreeView control

Syntax 2

Windows and other controls

Syntax 3


For information about the DataWindow control's DragDrop event, see the the section called “DragDrop” in DataWindow Reference.

Syntax 1: For ListBox, PictureListBox, ListView, and Tab controls

Description

Occurs when the user drags an object onto the control and releases the mouse button to drop the object.

Event ID

Event ID

Objects

pbm_lbndragdrop

ListBox, PictureListBox

pbm_lvndragdrop

ListView

pbm_tcndragdrop

Tab


Arguments

Argument

Description

source

DragObject by value (a reference to the control being dragged)

index

Integer by value (the index of the target ListView item)


Return Values

Long.

Return code choices (specify in a RETURN statement):

0 -- Continue processing

Usage

Obsolete functions

You no longer need to call the DraggedObject function in a drag event. Use the source argument instead.

Examples

For ListView controls, see the example for BeginDrag.

This example inserts the dragged ListView item:

This.AddItem(ilvi_dragged_object)
This.Arrange( )

See also

BeginDrag

BeginRightDrag

DragEnter

DragLeave

DragWithin

Syntax 2: For TreeView controls

Description

Occurs when the user drags an object onto the control and releases the mouse button to drop the object.

Event ID

Event ID

Objects

pbm_tvndragdrop

TreeView


Arguments

Argument

Description

source

DragObject by value (a reference to the control being dragged)

handle

Long by value (the handle of the target TreeView item)


Return Values

Long.

Return code choices (specify in a RETURN statement):

0 -- Continue processing

Usage

Obsolete functions

You no longer need to call the DraggedObject function in a drag event. Use the source argument instead.

Examples

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)

See also

DragEnter

DragLeave

DragWithin

Syntax 3: For windows and other controls

Description

Occurs when the user drags an object onto the control and releases the mouse button to drop the object.

Event ID

Event ID

Objects

pbm_bndragdrop

CheckBox, CommandButton, Graph, InkEdit, InkPicture, Picture, PictureHyperLink, PictureButton, RadioButton

pbm_cbndragdrop

DropDownListBox, DropDownPictureListBox

pbm_dragdrop

DatePicker, MonthCalendar

pbm_endragdrop

SingleLineEdit, EditMask, MultiLineEdit, StaticText, StaticHyperLink

pbm_omndragdrop

OLE

pbm_prndragdrop

HProgressBar, VProgressBar

pbm_rendragdrop

RichTextEdit

pbm_sbndragdrop

HScrollBar, HTrackBar, VScrollBar, VTrackBar

pbm_uondragdrop

UserObject

pbm_dragdrop

Window


Arguments

Argument

Description

source

DragObject by value (a reference to the control being dragged)


Return Values

Long.

Return code choices (specify in a RETURN statement):

0 -- Continue processing

Usage

When a control's DragAuto property is true, a drag operation begins when the user presses a mouse button.

Obsolete functions

You no longer need to call the DraggedObject function in a drag event. Use the source argument instead.

Examples

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

See also

DragEnter

DragLeave

DragWithin