File Exchange

image thumbnail

Drag and Drop

version (1.31 KB) by Raphael Austin
Drag and Drop to and from Matlab Figure


Updated 10 Sep 2007

No License

Example Drag and Drop in Matlab Figures from Windows Explorer or Other Apps

DrapDropTest creates a simple figure which shows the implementation of dnd using activex.
The microsoft RichtextCtrl.1 activex control is used to demonstrate dnd ability. The control
has several events to which matlab can respond, in particular the OLEDragDrop Event.

Type DragDropTest from the command line to test. Once the figure is
running try dragging a text file into either of 2 areas on the figure.
The upper portion will just populate a listbox with the names of files
that have been dragged into the bar above it. The lower box displays the
contents of any text file dragged into it. The bottom box also allows
text to be dragged from a text editor such as wordpad.

This example is not intended to be robust, so please feel free to use it,
but make sure to check over the code in detail to make sure it doesn't
break. I've just coded this quickly to demonstrate the property. Feel
free to email me with questions comments.

Cite As

Raphael Austin (2020). Drag and Drop (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (18)


コントロールを作成できませんでした。ProgID 'RICHTEXT.RichtextCtrl.1' が無効です。

What do we do for Win64 - MATLAB64?

very good!

MATLAB version can be found using command computer

>> computer
PCWIN (returned as answer) - x86 (32bit, MATLAB Ver)

PCWIN64 (returned as answer - x64 (64bit, MATLAB Ver)

Explaining this issue in more detail

The error are due to mismatch between Windows Ver and MATLAB version

Win64 - MATLAB64 then richtx32.ocx is not compatible

Win64 - MATLAB32 then richtx32.ocx issue can be resolve what I have mentioned

Win32 - MATLAB32 -No Issue by default and if issue then can be resolve what I mentioned

Hello Everyone

RICHTEXT.RichtextCntrl.1 requires registration of activex in activexcontrol list

First Check if MATLAB returns specified Activex control

list = actxcontrollist;

if list not contain "RICHTEXT" activex then it require to register

for x64 , use following in "cmd" with Admin rights
regsvr32 C:\Windows\SysWOW64\richtx32.ocx

for x86
regsvr32 C:\Windows\System32\richtx32.ocx

After that it will popup msgbox that Richtext registered successfully

ProgID='RICHTEXT.RichtextCtrl.1' can be use in MATLAB without error

chen xinfeng

An error:DragDropTest (line 36)
h1 = actxcontrol(ProgID, [pos(3)*.1 355 pos(3)*.8 20],f,{'OLEDragDrop',@ShowFileNameOnDrop});

How to fix it??


This problem is 'RICHTEXT.RichtextCtrl.1' doesn't look available for Windows x64.
Does anyone succeed to do the same thing for a x64 ?
I am using R2013b.


Hi, I tried this but I get an error:
"Error using actxcontrol (line 185)
Control creation failed. Invalid ProgID 'RICHTEXT.RichtextCtrl.1' "

I am using R2011b


Y Mehta

I get the following error. Am I missing an activeX control? If yes, how to get it?

??? Error using ==> feval
Input PROGID does not represent an Activex control.
If this PROGID used to work before, please check vendor's
documentation for equivalent activex control progid.

Error in ==> actxcontrol>createControl at 240
ctrl = feval(comstr, 'control', position, parent, '', filename, hwnd, licensekey,

Error in ==> actxcontrol at 212
hControl = createControl;

Error in ==> DragDropTest at 36
h1 = actxcontrol(ProgID, [pos(3)*.1 355 pos(3)*.8 20],f,{'OLEDragDrop',@ShowFileNameOnDrop});

Alan Brooks

Agreed that Lukas's statement should be a comment, not a rating. I would also like to know a cross-platform way of doing it, but have found none to date.

That's a ridiculous reason for a bad rating. If you can find a way to do it without ActiveX, then submit it. I'd love to use it. Be part of the solution.

Lukas Rohr

ActiveX can't be used on other Operating Systems


Great example. Now if I could figure out how to make this control invisible and cover an entire figure so you can drag-and-drop to anywhere...

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux