Table of Contents

OpenInsight Drag and Drop

OpenInsight now includes the ability to implement Drag and Drop capabilities within you application. This document outlines the concept, elements, events and properties of Drag and Drop within OpenInsight.

Overview

General Properties

System Properties

DragSource Properties

DragSource Messages

DropTarget Properties

DropTarget Events

Overview

Drag and Drop functionality is built around three basic elements:

  1. A Drag Source window/control
  2. A Drop Target window/control

These elements interact with each other in the following way:

The Drag Source

The Drag Source is defined as the control or window that is capable of having data dragged from it. It is responsible for:

In OpenInsight, a window or control is flagged as a Drag Source by setting its ENABLEDRAG property to TRUE$, either dynamically at runtime, by setting a PS style bit in the Form Designer or through the use of the ADD_DND system tool.

The Data Object

The Data Object is created to hold the data that is to be dragged. This data does not necessarily have to be in one format. Applications that use Drag and Drop frequently place more than one format in the Data Object – this allows target controls and applications to pick which format they prefer giving the Drag and Drop operation more chance of success.

The Data Object is populated by the Drag Source when the drag operation begins, and queried by a Drop Target during and on completion of a drag drop process.

The Data Object is created and managed internally by OpenInsight. It may be modified by the Drag Source when first created during a DRAGSTART event, and queried by the Drop Target during the DRAGOVER and DROPDROP events.

When created, OpenInsight usually fills the Data Object with one or more data formats.

The Drop Target

A Drop Target is defined as a control or window that can accept and respond to notifications that data is being dragged over it. It is responsible for:

In OpenIsight, a window or control is flagged as a drop target by setting it’s ENABLEDROP property to TRUE$, either dynamically at runtime, by setting a PS style bit in the Form Designer or through the use of the ADD_DND system tool.

General Properties

The following properties are used to control the basic Drag and Drop operations:

ENABLEDRAG property

Set this property to TRUE$ to enable data to be dragged from a control. OpenInsight will monitor mouse messages sent to the control and will detect if the user attempts to drag data from them.

Applies To : All controls except OLE controls.

Remarks:

drag_20and_20drop_image002.jpg

See also: DRAGSOURCE property, DRAGSTART, DRAGEND events

ENABLEDRAGROWS property

Set this property to TRUE to allow selected rows to be dragged in an edit table. If this flag is not set only data from single cells is allowed to be dragged (if their COLSTYLE is set accordingly).

Applies To: EDITTABLE

Remarks:

drag_20and_20drop_drag_20and_20drop_drag_20and_20drop_image004.jpg

See also: ENABLEDRAG property, COLSTYLE message.

ENABLEDRAGLIST property

Set this property to TRUE$ to allow combobox drag source controls to register their list component as a drag source too.

Applies To: COMBOBOX controls

Remarks:

drag_20and_20drop_image006.jpg

See also: ENABLEDRAG property

ENABLEDROP property

Set this property to TRUE$ to mark the control as a drop target, which means that the control will be notified when data is dragged over it.

Applies To: All controls except OLE controls.

Remarks:

drag_20and_20drop_drag_20and_20drop_image008.jpg

See also: DROPTARGET property, DRAGOVER, DRAGDROP events

ENABLEDROPSCROLL property

Set this property to TRUE$ to allow a drop target control to response to mouse hover notifications while data is dragged over it. In most cases this performs automatic scrolling of the drop target control when near the edge of the control’s client area.

Applies To: All controls except OLE controls.

Remarks:

drag_20and_20drop_drag_20and_20drop_image008.jpg

ENABLEDROPEXPAND property

Set this property to TRUE$ to allow a hierarchical lisbox drop target control to response to mouse hover notifications but expanding a node automatically.

Applies To: Hierarchical LISTBOX controls

Remarks:

drag_20and_20drop_drag_20and_20drop_drag_20and_20drop_image004.jpg

ENABLEDROPLIST property

Set this property to TRUE$ to allow simple combobox drop target controls to register their list component as a drop target too.

Applies To: Simple COMBOBOX controls

Remarks:

drag_20and_20drop_drag_20and_20drop_drag_20and_20drop_image004.jpg

SYSTEM properties

The following properties apply to the SYSTEM object:

DRAGSOURCE property

Contains the name of the OpenInsight control that is the “drag source” during a drag-drop operation. Read-only.

DROPTARGET property

Contains the name of the OpenInsight control that is currently the target of a DragDropoperation (if any). Read-only.

Drag Source Properties

The following properties apply to the current Drag Source control. The majority of them are only effective during a DRAGSTART event:

DRAGBUTTON property

Contains a number specifying which mouse button was used to start the drag operation. Read-only.

Applies To: The control that is currently the drag source (see the SYSTEM DRAGSOURCE property)

DRAGCELLPOS property

Contains the cell position of data being dragged from an edit table in the format:

Column : @fm : Row

Applies to: EDITTABLE when the control is currently the drag source (see the SYSTEM DRAGSOURCE property) and cell data is being dragged.

See also: DRAGTEXTSELECTION property.

DRAGCOPY property

Returns or sets a flag denoting if the drag source allows a COPY operation. This property should be set during the DRAGSTART event to override the default copy setting.

Applies To: Any control that is flagged as drag enabled (i.e. it’s ALLOWDRAG property is TRUE).

See also: ALLOWDRAG, DRAGMOVE properties.

DRAGFORMATLIST property

Contains an @fm-delimited list of data formats being dragged. Read-only.

Applies To: The control that is currently the drag source (see the SYSTEM DRAGSOURCE property)

Remarks:

Control TypeFormatsNotes
BITMAPBITMAP
FILENAME(if applicable)
COMBOBOX (Item)TEXT
COMBOBOX (List)OI_LIST@fm-delimited list
TEXTCRLF-delimited list
EDITLINETEXT
EDITBOXTEXTCRLF-delimited text
EDITTABLE (Cell)TEXT
EDITTABLE (Rows)OI_EDT_ROWLIST@fm/@vm-delimited list
TEXTCRLF/TAB delimited list
LISTBOXOI_LIST@fm-delimited list
TEXTCRLF-delimited list

See also: GETDRAGDATA, SETDRAGDATA, REMOVEDRAGDATA and CLEARDRAGDATA messages

DRAGMOVE property

Returns or sets a flag denoting if the drag source allows a MOVE operation. This property should be set during the DRAGSTART event to override the default move setting.

Applies To: Any control that is flagged as drag enabled (i.e. it’s ALLOWDRAG property is TRUE).

See Also: ALLOWDRAG, DRAGCOPY properties.

DRAGPOS property

Contains the client coordinates of the mouse (i.e relative to the control’s client area) when the drag operation started. Read-Only.

Property is returned in the format:

xPos : @fm : yPos

Applies To: The control that is currently the DragSource (see the SYSTEM DRAGSOURCE property)

DRAGSELROWCOUNT property

Contains the number of rows being dragged from a row-oriented control.

Applies To: LISTBOX, EDITTABLE when the control is currently the drag source (see the SYSTEM DRAGSOURCE property) and row data is being dragged.

See also: DRAGSELROWS property

DRAGSELROWS property

Contains the row numbers of the data being dragged from a row-oriented control. Multiple row numbers are @fm delimited.

Applies To: LISTBOX, EDITTABLE when the control is currently the drag source (see the SYSTEM DRAGSOURCE property) and row data is being dragged.

See also: DRAGSELROWCOUNT property

DRAGTEXTSELECTION property

This property contains the starting point and length of selected text used for a drag operation in the format

 
startPos : @fm : length

Applies to: EDITLINE, EDITBOX, EDITTABLE when the control is currently the drag source (see the SYSTEM DRAGSOURCE property)

DragSource messages

The following messages apply to the current Drag Source control. The majority of them are only effective during a DRAGSTART event:

GETDRAGDATA message

This message is used to extract data of a specified format from a dragged data object. It may be used against both drag source and drop target controls in all drag-drop related events.

dragData = Send_Message( ctrlEntID, “GETDRAGDATA”, format, unicode, maxlen)

Arguments

ArgumentDescription
ctrlEntIDMust be a current drag source or drop target control (See the SYSTEM DRAGSOURCE and DROPTARGET properties)
formatName of the format that you want to extract. This can be a custom format or one of the following standard OI data formats:

“TEXT” - Returns dragged textual data and automatically handles any Unicode translations required
“FILENAME” - Returns a dragged filename.
“BITMAP” - Returns a dragged bitmap handle. See notes below regarding dragged bitmap handles for further information.
unicodeWhen using a custom textual format set this flag to true for OI to perform a Unicode to UTF8/ANSI translation automatically if you know the data is a Unicode string.
maxlenWhen using a custom format and extracting binary data set this to the maximum number of bytes that OI should extract.

Returns

The dragged data for the specified format.

Remarks

SETDRAGDATA message

This message is used to set the data for a nominated format for a drag source control.

retVal = Send_Message( ctrlEntID, “SETDRAGDATA”, format, unicode, data )

Arguments

ArgumentDescription
ctrlEntIDMust be a current drag source control (See the SYSTEM DRAGSOURCE property)
formatName of the format that you want to set. This can be a custom format or one of the following standard OI data formats:

“TEXT” - Sets textual data in both ANSI and Unicode format
“FILENAME” - Sets a filename data format.
“BITMAP” - Sets BITMAP a bitmap data format. The data should be a bitmap path (see BITMAP property)
unicodeWhen using a text-based custom format set this flag to true for OI to perform a UTF8/ANSI to Unicode translation automatically before setting the data.
dataThe data to set.

Returns

TRUE$ if the data was set correctly, FALSE$ otherwise

Remarks

REMOVEDRAGDATA message

This message is used to remove the specified data format from the dragged data.

retVal = Send_Message( ctrlEntID, “REMOVEDRAGDATA”, format )

Arguments

ArgumentDescription
ctrlEntIDMust be a current drag source control (See the SYSTEM DRAGSOURCE property)
formatName of the format that you want to remove. This can be a custom format or one of the following standard OI data formats:

“TEXT” - Sets textual data in both ANSI and Unicode format
“FILENAME” - Sets a filename data format.
“BITMAP” - Sets BITMAP a bitmap data format. The data should be a bitmap path (see BITMAP property)

Returns

TRUE$ if the data was removed, FALSE$ otherwise

Remarks

CLEARDRAGDATA message

This message removes all data from the drag source data object. This can be used during a DRAGSTART event to cancel the drag if you wish.

retVal = Send_Message( ctrlEntID, “CLEARDRAGDATA”, format )

Arguments

ArgumentDescription
ctrlEntIDMust be a current drag source control (See the SYSTEM DRAGSOURCE property)

Returns

TRUE$ if the data was removed, FALSE$ otherwise

Remarks

SETDRAGBITMAP message

This message sets the bitmap used by the system when dragging data from the drag source.

retVal = Send_Message( ctrlEntID, “SETDRAGBITMAP”, bmp, xOffset, yOffset, tc )

Arguments

ArgumentDescription
ctrlEntIDMust be a current drag source control (See the SYSTEM DRAGSOURCE property)
bmpPath of the bitmap image to use – see the BITMAP property.
xOffsetX offset of the image from the cursor hotspot
yOffsetY offset of the image from the cursor hotspot
tcColor to use as the transparent color if the image has transparent parts

Returns

TRUE$ if the image was created, FALSE$ otherwise

Remarks

DragSource Events

These events apply to a control registered as a “drag source” (i.e. it’s ENABLEDRAG property is TRUE).

DRAGSTART event

This event is fired in response to a drag operation beginning on a control. This means that the user has clicked a mouse button down on a control and has begun to drag. The main tasks that should be addressed in this event are (in no particular order):

Event Parameters

ParameterDescription
MouseDownXx coordinate where the drag started (relative to the client area)
MouseDownYy coordinate where the drag started (relative to the client area)
CtrlKeyTRUE$ if the Ctrl key was held down when the drag was started
ShiftKeyTRUE$ if the Shift key was held down when the drag was started
AltKeyTRUE$ if the Alt key was held down when the drag was started
MouseButtonDenotes which mouse button was held down when the drag was started:

‘0’ - Left Mouse Button
‘1’ - Right Mouse Button
‘2’ - Middle Mouse Button

Remarks

DRAGEND event

This event is fired after a drop operation has ended and is used to inform the drop source of the results of the operation. The main tasks that should be addressed in this event are (in no particular order):

Event Parameters

ParameterDescription
DragResultResult of the DragDrop operation. Can be one of the following:

‘CANCEL’
‘COPY’
‘MOVE’

Remarks

DropTarget properties

DROPACCEPT property

Set to FALSE$ during a DRAGOVER event to stop OI performing any more data comparisons against the drop target until the control is entered again.

Applies To: The control that is currently the drop target (see the SYSTEM DROPTARGET property)

See also: DRAGFORMATLIST, DROPFORMATLIST properties, DRAGOVER, DRAGDROP events

Remarks

* This property is basically an optimization technique. If you are sure that the control will not accept the current drag data at any point during the operation then set this property to FALSE$ will save processing time. * It is reset to TRUE$ whenever drag data enters the control again (i.e. the DRAGOVER ENTER event)

DROPCOPY property

Set this property to TRUE$ to allow the drag data to be copied to the drop target.

Applies To: The control that is currently the drop target (see the SYSTEM DROPTARGET property)

See also: DRAGMOVE property, DRAGOVER, DRAGDROP events

Remarks

DRAGFORMATLIST property

Returns an @fm delimited list of data formats being dragged. Read-only. OI compares the list of formats defined in the control’s DROPFORMATLIST property against the formats in the DRAGFORMATLIST property to determine if a drag can be made or not.

Applies To: The control that is currently the drop target (see the SYSTEM DROPTARGET property)

See also: Drop Source DRAGFORMATLIST property, DRAGOVER, DRAGDROP events

DROPFORMATLIST property

Returns an @fm delimited list of data formats accepted by the control and should be sorted in order of preference. During DRAGOVER events the system will examine the data being dragged and compare it to the formats in this list, selecting the first match it finds.

Applies To: Any control defined as a drop target.

See also: DRAGOVER, DRAGDROP events. DROPTARGET property.

DROPTYPE property

Used during the DRAGDROP event to let the system know what operation took place. Can be either “MOVE” or “COPY”.

See also: DRAGDROP event

DROPMOVE property

Set this property to TRUE$ to allow the drag data to be moved to the drop target.

Applies To: The control that is currently the drop target (see the SYSTEM DROPTARGET property)

See also: DRAGCOPY property, DRAGOVER, DRAGDROP events

Remarks

DROPRESULT property

When set during a DRAGDROP event it prevents the OI from performing any default data copy or move operations after the event returns. Basically you are saying that you have handled all operations necessary and that OI should perform no further processing after the DRAGDROP event returns.

Values you may set are:

This value will be passed to the DRAGSOURCE DRAGEND event if appropriate.

Applies To: The control that is currently the “drop target” (see the SYSTEM DROPTARGET property)

Remarks: This property can only be set during a DRAGDROP event. If is reset to null at the start of every DRAGDROP event.

DropTarget Events

These events apply to controls registered as “drop targets” (i.e. one of the following properties is TRUE: ENABLEDROP,ENABLEDROPHOVER or ENABLEDROPEXPAND).

DRAGOVER event

This event is fired at a drop target control in response to data being dragged into, over and out of it. For this reason there are four separate subcategories:

1. DragEnter: Data has been dragged into the drop target. The main tasks that should be addressed at this point are (in no particular order):

2. DragMove: Data is being dragged across a control. The main tasks that should be addressed at this point are (in no particular order):

3. DragHover: The mouse is hovering over the control while dragging data. The main tasks that should be addressed at this point are (in no particular order):

4. DragLeave: The data has been dragged out of the control without being dropped. The main tasks that should be addressed at this point are (in no particular order):

Event Parameters

ParameterDescription
DragEventDescribes the type of DRAGOVER event taking place. Can be one of the following:

“ENTER” - Data has been dragged onto a control for the first time
“MOVE” - Data is being dragged across a control
“HOVER” - Mouse is hovering above a control with dragged data
“LEAVE” - The data has been dragged outside of the control
MouseXx coordinate of the mouse (relative to the client area)
MouseYy coordinate of the mouse (relative to the client area)
CtrlKeyTRUE$ if the Ctrl key is held down
ShiftKeyTRUE$ if the Shift key is held down
AltKeyTRUE$ if the Alt key is held down
MouseButtonDenotes which mouse button is being held down:

‘0’ - Left Mouse Button
‘1’ - Right Mouse Button
‘2’ - Middle Mouse Button

Remarks

DRAGDROP event

This event is fired at a drop target control when the user has dropped data onto it. The main tasks that should be addressed at this point are (in no particular order):

Event Parameters

ParameterDescription
DataFormatContains the name of the dropped data format
DropResultContains the desired action – MOVE or COPY.
xDownx coordinate where the data was dropped (relative to the client area)
yDowny coordinate where the data was dropped (relative to the client area)
CtrlKeyTRUE$ if the Ctrl key was held down when the data was dropped
ShiftKeyTRUE$ if the Shift key was held down when the data was dropped
AltKeyTRUE$ if the Alt key was held down when the data was dropped
MouseButtonDenotes which mouse button was held down when the data was dropped:

‘0’ - Left Mouse Button
‘1’ - Right Mouse Button
‘2’ - Middle Mouse Button

Remarks