Public Member Functions

IDragAndDropMgr Class Reference

This reference page is linked to from the following overview topics: Incremental Improvements.


Search for all occurrences

Detailed Description

Manager class for Drag and Drop The Drag and Drop system is managed through a Core FP interface (DND_MGR_INTERFACE), defined by this class.

It provides control over the drag and drop system, manages handler registration and exposes some useful utility methods for downloading URL's, simulating drops, etc.

The DragAndDropMgr supports multiple DragAndDropHandler's registered against a single HWND window. This allows new components and 3rd-party developers to incrementally add handlers for new dropTypes to common windows such as viewports, that the default handlers don't know how to handle.

The IDragAndDropMgr::EnableDandD(HWND hwnd, BOOL flag, DragAndDropHandler* handler) method can be called multiple times on the same window with different handler instances. The drag and drop manager keeps track of all the DragAndDropHandlers on each window and will call their drag and drop event methods as needed, in order of registration, until one of them returns S_OK. For example, on a viewport, the DefaultDragAndDropHandler is registered by default. The event methods (such as DragEnter, DragOver, Drop, etc.) return E_FAIL if the dropping IDataObject or DropType is not recognized by them. Then, if a new component registers its own handler to deal with some new droptype, the default handler will fail to recognize the new droptype and so the new handler will be called to process the new drop type.

Note that this means DragAndDropHandler event methods must correctly return S_OK or E_FAIL depending on whether they handle the IDataObject or DropType currently dropping, so that the appropriate handler is found and called by the DnDMgr.

In Max 2011, the management of DragAndDropHandler memory lifetime has been changed. In previous versions, it was up to 3rd party developers to 'unregister' (Passing in FALSE to IDragAndDropMgr::EnableDandD) their drag and drop handlers (DragAndDropHandler*), before max was shutdown. If they didn't max would crash on shutdown. Now, unitialization has been moved up before 3rd party plugins are unloaded. Now, the manager automatically 'unregisters' all DragAndDropHandler pointers during a broadcast of NOTIFY_SYSTEM_SHUTDOWN. This means that the manager calls DragAndDropHandler::Release on all DragAndDropHandler pointers registered with it. After the manager cleans up during the NOTIFY_SYSTEM_SHUTDOWN broadcast, any subsequent calls to register a drag and drop handler will return FALSE. Also any subsequent calls to 'unregister' a handler will just silently do nothing.

See also:
Class FPStaticInterface, Class DragAndDropHandler, Class URLTab

#include <idraganddrop.h>

Inheritance diagram for IDragAndDropMgr:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void  EnableDandD (BOOL flag)=0
  Globally enables or disables the drag and drop interface.
virtual BOOL  IsEnabled ()=0
  returns TRUE if the global drag and drop interface is enabled, otherwise FALSE.
virtual BOOL  EnableDandD (HWND hwnd, BOOL flag, DragAndDropHandler *handler=NULL)=0
  Enables drag and drop for a given window (and its children).
virtual BOOL  DropPackage (HWND hwnd, POINT &point, URLTab &module)=0
  This method allows the simulation of a module of files into a window at a given point.
virtual BOOL  DownloadPackage (URLTab &module, MCHAR *directory, HWND hwnd=NULL, bool showProgress=false)=0
  Used to download a module of URLs to the specified directory.
virtual MCHAR *  GetDownloadDirectory ()=0
  Returns the fully-specified path to the directory in which module drops are downloaded.
virtual int  NumHandlers (HWND hwnd)=0
  Gets the number of handlers associated with the given window.
virtual DragAndDropHandler GetHandler (HWND hwnd, int i)=0
  Returns a pointer to a specified drag and drop hander of a specified window.
virtual bool  DownloadUrlToDisk (HWND hwnd, MCHAR *url, MCHAR *fileName, DWORD dlgflags=0)=0
  Downloads the file referenced by the URL to disk.
virtual INode ImportContextNode ()=0
  Returns a pointer to the import context node.

Member Function Documentation

virtual void EnableDandD ( BOOL  flag ) [pure virtual]

Globally enables or disables the drag and drop interface.

Parameters:
flag - TRUE to enable, FALSE to disable.
virtual BOOL IsEnabled ( ) [pure virtual]

returns TRUE if the global drag and drop interface is enabled, otherwise FALSE.

virtual BOOL EnableDandD ( HWND  hwnd,
BOOL  flag,
DragAndDropHandler handler = NULL 
) [pure virtual]

Enables drag and drop for a given window (and its children).

If no custom DragAndDropHandler is supplied, a default one is used that will accept dropped scene files for opening and scripts for running. When the application is shutting down, it is prohibited to enable or disable a handler. Therefore after a NOTIFY_SYSTEM_SHUTDOWN broadcast this method will always return FALSE.

Parameters:
hwnd - A handle to the window you wish to enable or disable drag and drop for.
flag - TRUE to enable, FALSE to disable.
handler - A pointer to a custom drag and drop handler, or NULL to accept a default one.
Returns:
TRUE if the method was successful, otherwise FALSE.
virtual BOOL DropPackage ( HWND  hwnd,
POINT &  point,
URLTab module 
) [pure virtual]

This method allows the simulation of a module of files into a window at a given point.

A module of files, specified as a list of URL strings is the common form of DropType data from iDrop sources and files dragged from the Windows desktop. The entire module is downloaded, as needed, but only the first file in the list is actually dropped into 3ds Max. The other files in the module are presumed to be support files, such as texmaps or xref sources, for the main drop file.

After the drop, the URL strings in the URLTab are converted to fully-specified path names to local file copies, if any had to be downloaded from the web.

Parameters:
hwnd - A handle to the window. If this is set to NULL, the default 3ds Max window is used.
point - The point at which to drop.
module - A reference to the local copies of the URL strings.
Returns:
TRUE if the drop was successful, otherwise FALSE.
virtual BOOL DownloadPackage ( URLTab module,
MCHAR *  directory,
HWND  hwnd = NULL,
bool  showProgress = false 
) [pure virtual]

Used to download a module of URLs to the specified directory.

If the hwnd argument is supplied, any progress or other messages are centered over that window.

Parameters:
module - A reference to the local copies of the URL strings.
directory - The directory path string to download to.
hwnd - A handle to the window. If this is set to NULL, the default window is used.
showProgress - The download progress dialog can be displayed by passing true.
Returns:
TRUE if the download was successful, otherwise FALSE.
virtual MCHAR* GetDownloadDirectory ( ) [pure virtual]

Returns the fully-specified path to the directory in which module drops are downloaded.

virtual int NumHandlers ( HWND  hwnd ) [pure virtual]

Gets the number of handlers associated with the given window.

Parameters:
hwnd - A handle to the window.
virtual DragAndDropHandler* GetHandler ( HWND  hwnd,
int  i 
) [pure virtual]

Returns a pointer to a specified drag and drop hander of a specified window.

Parameters:
hwnd - A handle to the window.
i - The I-th handler.
virtual bool DownloadUrlToDisk ( HWND  hwnd,
MCHAR *  url,
MCHAR *  fileName,
DWORD  dlgflags = 0 
) [pure virtual]

Downloads the file referenced by the URL to disk.

Parameters:
hwnd - A handle to the window.
url - The URL string of the file to download.
fileName - The filename string of the URL to store on disk.
dlgflags - Additional controls to the download behavior. Currently only one flag is supported, DOWNLOADDLG_NOPLACE, which hides an option in the progress dialog that allows the user to place (move) a dropped object immediately after being dropped.
Returns:
TRUE if the download was successful, otherwise FALSE.
virtual INode* ImportContextNode ( ) [pure virtual]

Returns a pointer to the import context node.


IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr
IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr IDragAndDropMgr