Remove drag and drop event handler


from a few max release drag-drop suddenly stops working.
i found there is a drop handler that is not going to be released, infact the result of DragAndDropMgr.NumHandlers on scenes that are working ok is 0 and 1 in the broken ones.

i’m not too familiar with the dotnet side of things so i’m even unable to run DragAndDropMgr.GetHandler correctly, nor to dispose that handler by any means. here is what i’m working on

global	g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance

local hwnd = 6823308P  ----the viewport hwnd
local numhand = g.DragAndDropMgr.NumHandlers(hwnd)

g.DragAndDropMgr.GetHandler(hwnd numhand)

---g.DragAndDropMgr.(GetHandler(hwnd numhand)).Release()    -----this is what i'd like to do

i can barely get the numhand but i’m missing something in the gethandler part.
thank you for any help


see if that helps

fn asPtr hwnd = dotNetObject "system.intptr" hwnd

g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance

dnd_handlers = #()

for i = 1 to viewport.numViews do
	view = g.coreinterface14.GetViewExp (dotNetObject "system.int32" (i - 1))
	format "view: %\n" (view.ViewType.toString())

	view_hwnd = asPtr view.hwnd
	handlers_count = g.DragAndDropMgr.NumHandlers view_hwnd
	join dnd_handlers (for i = 1 to handlers_count collect g.DragAndDropMgr.GetHandler view_hwnd (i - 1))


for d in dnd_handlers do d.Release()


hi, thank you.
it does not work in my case, handler still there
but certantly it helped a lot
thank you


i found this on the sdk about the release method

You should provide an implementation if you need to keep track of extant uses of the handler (say, by ref-counting) or to do handler-specific cleanup.

what does this “provide an implementation” means? thanks

also i can’t understand the difference between dragAndDrop and IDragAndDrop they output this



I doubt that you can fix it with any of these as well. In sdk comments it says that this .Release method used on dnd manager shutdown and only if you need some specific cleanups then you must provide a custom implementation of this method.

Are you sure that it is indeed your script that breaks drag-drop functionality?


yes that’s exactly the case. unfortunately after some time the drop stops working.

you can see it also in this page

namely this part

  • drag and drop from Connector - in case 3ds max drag and drop does not work (known bug in new 3ds max version)

and i finally found a possible scenario, it seems that there is an handler that at some point wont close itself.

thhis could be the case

i think in pixamoon’s script he just merge the file taking the string form fArr variable in the dropscript connecter provides, i wrote myself such a tool but now i think i’m closer to the real problem!

but still i cant kill that handle :slight_smile:

i tried to disable and re enable the dnd manager but the handler seems not connected to thad.


ok, then you could try to destroy view panel with all the viewports (since dnd handler is binded to a particular viewport it might help)
see ViewPanelManager in mxs docs

unfortunately after some time the drop stops working

what code do you use to drop things to viewport?


thanks, i’ll definetly have a look to the viewpanel
the break on drop is not by my scripts but from an unknown source
i even removed all my scripts and installed a new vanilla max. but no way i was able to detect the guilty

it seems that connecter breaks the drop, it seems…not that it does.i’m not sure
but for sure i’m not the only one having this problem (hence pixamoon built a workaround and too i did)

my version of the “dropper” is similar to pixamoons i guess, so i take the fArr value from the ds and use a standard mergemaxfile from the original path