# MX\_DRAGDROP

> [HTML Version](mx_dragdrop.htm)

_Added July 2021_

**xcall MIAMEX, MX\_DRAGDROP, opcode, status, ctlid \{,fidx ,fspec\}**

MX\_DRAGDROP (MIAMEX 199) provides support for accepting files dragged and dropped from Windows File Explorer—or another Windows Shell object—onto a control created with AUI\_CONTROL.

This function has both a [subroutine and a print tab implementation](subroutine-print-pairs.md).

To enable the feature, specify the WS\_EX\_ACCEPTFILES (\&h0010) flag in the _winstylex_ parameter of the AUI\_CONTROL call when creating the target control. Typically this would be a static control, perhaps with a colored background and some explanatory text (e.g. “"Drop files here"), but in theory it could be nearly any control type—including dialogs—that are created with AUI\_CONTROL.

Two modes are supported: destructive and non-destructive. In the destructive mode, each drop event replaces the existing contents of the drop buffer with the newly dragged file specs, as with a clipboard Copy. In the non-destructive mode, each drop event adds to the existing contents of the drop buffer. Destructive mode is the default. Non-destructive mode is established via MX\_DRAGDROP _opcode_ 3 after creating the drop target control.

In both modes, the drop event triggers exitcode -75,notifying the application so that it can respond by querying and/or retrieving the filespecs using the MX\_DRAGDROP function. 

**Parameters**

_opcode_  ([Num](num.md))  \[in\]

| **Value** | **Description** |
|------|------|
| 0 | query drop buffer, set _status_ parameter to the number of files in the drop target (_ctlid_) |
| 1 | retrieve _fspec_ corresponding to _fidx_ from the specified drop target (_ctlid_) |
| 2 | clear the contents of the drop target buffer |
| 3 | set non-destructive (previous "asynchronous") mode |




_status _ (Signed [Num](num.md))  \[out\]

<=0: failure, or no files available in opcode 0; >0: success, which is the number of files for _opcode_ 0, or the number of bytes in _fspec_ for _opcode_ 1

_ctlid_  ([String](string.md) )  \[in\]

control id of the target control

_fidx_  ([Num](num.md))  \[in\]

for _opcode_  1, must be set to the number of the _fspec_ to retrieve (starting with 1)

_fspec_  ([String](string.md) ) \[out\]

file specification returned for _opcode_ 1

**Comments**

Note that it isn’t actually the files themselves that are being dragged and dropped; it is just their file specifications. 

Although the implementation is primarily on the Windows side, accessing the new MX\_DRAGDROP feature from an ATE session will require that the server instance of A-Shell also be at least at version 6.5.1705.

There is nothing stopping you from defining more than one drop target control within a given UI context. But since all drop events trigger the same exitcode -75, you would need to query each of the possible drop target controls in order to identify which control received the drop event.

**Examples**

Create a drop target control—in this case, a static text control. The critical element here is the WS\_EX\_ACCEPTFILES value for the _winstylex_ parameter.…

\! create the drop target (must be MBF\_STATIC with WS\_EX\_ACCEPTFILES)

DROPCTLID\$ = “txtDropTarget”

xcall AUI, AUI\_CONTROL, CTLOP\_ADD, DROPCTLID\$, \&

    "Drop File(s) Here" + chr(13) + "Click to query", MBST\_ENABLE, \&

    MBF\_STATIC+MBF\_CENTER+MBF\_KBD, "VK\_xF100", NUL\_FUNC\$, NUL\_CSTATUS, \&

    srow,scol,erow,ecol, NUL\_FGC, \&hddccbb, \&

    NUL\_FONTATTR, NUL\_FONTSCALE, NUL\_FONTFACE\$, NUL\_TOOLTIP\$, \&

    DLGID\$, NUL\_WINCLASS\$, NUL\_WINSTYLE, WS\_EX\_ACCEPTFILES, \&

    NUL\_CTYPE2



Set asynchronous mode:

opcode  = 3

ctlid = DROPCTLID\$

xcall MIAMEX, MX\_DRAGDROP, opcode , status, ctlid



Query drop target to see how many files are available:

opcode  = 0

ctlid = DROPCTLID\$

xcall MIAMEX, MX\_DRAGDROP, opcode , status, ctlid

count = status   \! # of files in target



Retrieve file specifications from the drop target:

opcode  = 1

ctlid = DROPCTLID\$

for fidx = 1 to count   \! count retrieved from opcode 0

    xcall MIAMEX, MX\_DRAGDROP, opcode, status, ctlid, fidx, fspec\$

    ? “File #”;fidx;” : “;fspec\$

next fidx



**Also See**

•	The sample program [FILEDROP1.BP in EXLIB:\[908,90\]](https://bitbucket.org/microsabio/exlib/src/master/908090/filedrop1.bp) illustrating a simple drag-drop user interface.

**History**

2021 July, A-Shell 6.5.1705:  Routine added to A-Shell.