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, |
|
pbm_cbndragdrop |
DropDownListBox, |
|
pbm_dragdrop |
DatePicker, MonthCalendar |
|
pbm_endragdrop |
SingleLineEdit, EditMask, MultiLineEdit, |
|
pbm_omndragdrop |
OLE |
|
pbm_prndragdrop |
HProgressBar, VProgressBar |
|
pbm_rendragdrop |
RichTextEdit |
|
pbm_sbndragdrop |
HScrollBar, HTrackBar, VScrollBar, |
|
pbm_uondragdrop |
UserObject |
|
pbm_dragdrop |
Window |
Arguments
|
Argument |
Description |
|---|---|
|
source |
DragObject by value (a reference to the control |
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:
|
1 2 3 4 |
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:
|
1 2 3 4 5 6 7 8 9 10 11 |
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:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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