3ds Max C++ API Reference
DropScriptDropType Class Reference

#include <idraganddrop.h>

+ Inheritance diagram for DropScriptDropType:

Public Member Functions

int TypeCode ()
 
bool IsDropType (int code)
 
DWORD DropEffect ()
 
CoreExport BOOL CompileDropScript (const MCHAR *filename)
 
CoreExport BOOL RunDropScriptDragEnter (FPParams *params)
 
CoreExport BOOL RunDropScriptDragOver (FPParams *params)
 
CoreExport BOOL RunDropScriptDrop (FPParams *params)
 
CoreExport STDMETHODIMP GetData (FORMATETC *pFormatetc, STGMEDIUM *pmedium)
 
CoreExport STDMETHODIMP GetDataHere (FORMATETC *pFormatetc, STGMEDIUM *pmedium)
 
CoreExport STDMETHODIMP QueryGetData (FORMATETC *pFormatetc)
 
void InitDragDropCheck (MacroEntry *dropscript, LPARAM mousePt, WPARAM keyState, HWND hwnd)
 
bool ReadyToDrag ()
 
- Public Member Functions inherited from DropType
 DropType ()
 
virtual CoreExport ~DropType ()
 
virtual bool Load (bool showProgress=true)
 
CoreExport STDMETHODIMP QueryInterface (REFIID iid, void **ppvObject)
 
CoreExport STDMETHODIMP_ (ULONG) AddRef(void)
 
CoreExport STDMETHODIMP_ (ULONG) Release(void)
 
CoreExport STDMETHODIMP GetData (FORMATETC *pFormatetc, STGMEDIUM *pmedium)
 
CoreExport STDMETHODIMP GetDataHere (FORMATETC *pFormatetc, STGMEDIUM *pmedium)
 
CoreExport STDMETHODIMP QueryGetData (FORMATETC *pFormatetc)
 
CoreExport STDMETHODIMP GetCanonicalFormatEtc (FORMATETC *pFormatetcIn, FORMATETC *pFormatetcOut)
 
CoreExport STDMETHODIMP SetData (FORMATETC *pFormatetc, STGMEDIUM *pmedium, BOOL fRelease)
 
CoreExport STDMETHODIMP EnumFormatEtc (DWORD dwDirection, IEnumFORMATETC **ppenumFormatetc)
 
CoreExport STDMETHODIMP DAdvise (FORMATETC *pFormatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
 
CoreExport STDMETHODIMP DUnadvise (DWORD dwConnection)
 
CoreExport STDMETHODIMP EnumDAdvise (IEnumSTATDATA **ppenumAdvise)
 
CoreExport STDMETHODIMP QueryContinueDrag (BOOL fEscapePressed, DWORD grfKeyState)
 
CoreExport STDMETHODIMP GiveFeedback (DWORD dwEffect)
 
virtual CoreExport void InitDragDropCheck (LPARAM mousePt, WPARAM keyState, HWND hwnd)
 
virtual CoreExport void CancelDragDropCheck ()
 
virtual CoreExport bool DragDropCheck (LPARAM mousePt, WPARAM keyState, DWORD allowedEffects)
 

Static Public Attributes

static CoreExport MacroEntrycurrent_dropscript
 
- Static Public Attributes inherited from DropType
static CoreExport IDataObject * current_dataobject
 

Additional Inherited Members

- Static Public Member Functions inherited from DropType
static void Init ()
 
- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 
- Static Protected Attributes inherited from DropType
static CoreExport IDragAndDropMgrdndMgr
 
static CoreExport bool dragging
 
static CoreExport POINT startPt
 
static CoreExport WPARAM startKeyState
 
static CoreExport HWND startWnd
 
static CoreExport bool loaded
 

Detailed Description

See also
Class DropType, Class DragAndDropHandler, Class FPParams, Class MacroEntry, DropTypes
Description:
This class is an intermediate base class for drop content that comes in the form of a dropScript. This is a special kind of macroScript that implements dropScript event handlers (see the DropScript documentation for details.) The prime subclass is DropScriptFileDropType which recognizes files of type .ds. The parsed data for this type is a single parsed macroScript, represented as a MacroEntrypointer. The DropScriptDropType class provides utility methods for compiling a .ds file into the current_dropscript slot and for running the drag and drop-associated handlers in the current dropScript.

The methods RunDropScriptDragEnter(FPParams* params), RunDropScriptDragOver(FPParams* params) and RunDropScriptDrop(FPParams* params) take care of the 'on droppable' handler in the current_dropscript, if supplied. The DragAndDropHandler::DragEnter call is usualy made once on initial entry to a registered drag and drop target window and DragAndDropHandler::DragOver is usually called as the mouse moves over this window. In both cases, the handler returns true or false to indicate whether the dropping dropScript will be accepted. If a handler is not supplied, the dropScript is always deemed droppable. If the handler returns false, the not-droppable cursor is shown.

The handler is called with a set of arguments, supplied by the DragAndDropHandler, that usually depends on the window currently under the mouse pointer. For example, over a viewport, the current mouse coordinates, scene node under the mouse, slot number in a list window, etc. By convention, the first argument is positional and always a window type name, such as "Viewport" or "MaterialEditor", and all the others are keyword arguments, since they will vary from window to window. They are delivered to the RunDropScriptXXX methods in a Function Publishing FPParam object, so that handler code needs to deal as little as possible with the MAXScript SDK. Here's an example code fragment from the default drop handler:

FPParams params (6,
TYPE_NAME, (vpwin ? _M("viewport") : _M("max")),
TYPE_NAME, _M("node"),
TYPE_INODE, m_nodectx,
TYPE_NAME, _M("point"),
TYPE_POINT, &pt);
// run the dragEnter handler & set dropeffect based on result
*pdwEffect = DROPEFFECT_COPY;
else
*pdwEffect = DROPEFFECT_NONE;
CoreExport BOOL RunDropScriptDragEnter(FPParams *params)
This parameters class contains a MaxSDK::Array FPValue's.
Definition: ifnpub.h:953
CoreExport DropScriptFileDropType dropScriptFileDropType
@ TYPE_KEYARG_MARKER
MAXScript internal type.
Definition: paramtype.h:441
@ TYPE_POINT
Identifies a Win32 POINT argument type or return value.
Definition: paramtype.h:123
@ TYPE_NAME
Identifies a character string argument type or return value that corresponds to a MAXSCript name valu...
Definition: paramtype.h:128
@ TYPE_INODE
A pointer to an INode.
Definition: paramtype.h:77
#define _M(x)
Used to wrap string literals.
Definition: strbasic.h:67
In the above code, the handler is called with 3 actual arguments, one position and two keyword. They are loaded into the 'params' instance with the FPParams varargs constructor. The first is the positional window name, in this case either #viewport or #max, then comes a special TYPE_KEYARG_MARKER signalling that the following arguments are keyword. The keyword args are given in pairs, name then value, in this case node: and point:. See the Function Publishing system documentation for full details on using the FPParams class for passing parameter blocks. An example droppable handler might be as follows:

on droppable window node: do

return window == #viewport and superclassOf node == Shape

This handler effectively makes the dropScript droppable if the mouse is over a Shape object in a viewport window. Notice that the function only looks at the node: keyword argument in this definition; arguments delivered as keyword arguments can vary from call to call and the called function can choose to look at only subset of them.
Data Members:
public

static MacroEntry* current_dropscript;

Cache for current macroScript. See /MAXSDK/INCLUDE/iMacroScript.h for the MacroScript manager public API. There are also utility methods in DropScriptDropType that do all the necessary drag and drop compiling & running of macroScripts, so you only have to deal with the MacroScript manager for special processing.

Member Function Documentation

◆ TypeCode()

int TypeCode ( )
inlinevirtual
Remarks
This method returns the typecode of the DropType.
Default Implementation:
{ return DROPSCRIPT_DROPTYPE; }

Implements DropType.

Reimplemented in MSZipPackageFileDropType, and DropScriptFileDropType.

1091 { return DROPSCRIPT_DROPTYPE; }
#define DROPSCRIPT_DROPTYPE
A dropScript.
Definition: idraganddrop.h:862

◆ IsDropType()

bool IsDropType ( int  code)
inlinevirtual
Remarks
This method returns TRUE if the DropType is of the specified DropType code, otherwise FALSE.
Parameters:
int code

The DropType code.
Default Implementation:
{ return code == TypeCode() || code == DROPSCRIPT_DROPTYPE; }

Reimplemented from DropType.

1099 { return code == TypeCode() || code == DROPSCRIPT_DROPTYPE; }
int TypeCode()
Definition: idraganddrop.h:1091

◆ DropEffect()

DWORD DropEffect ( )
inlinevirtual
Remarks
This method returns the dropeffect currently supported by the accepted dropping type.
Default Implementation:
{ return DROPEFFECT_MOVE; }

The following methods provide assistance for developing custom drag-and-drop handlers that want to accept dropScripts. They work on the shared current_dropscript static data member in DropScriptDropType.

Reimplemented from DropType.

1107 { return DROPEFFECT_MOVE; }

◆ CompileDropScript()

CoreExport BOOL CompileDropScript ( const MCHAR filename)
Remarks
This method parses the given file, looking for a single macroScript definition. If successful, interns the macroScript and places its corresponding MacroEntry* in the current_dropscript static data member. Note that if there is more code than just a single macroScript in the file, only the last macroScript definition is taken; the other code is NOT executed, so you cannot include auxiliary global functions and other prep code in the file. These should be inside the body of the macroScript, as local data and functions.
Parameters:
MCHAR* filename

The filename of the script.
Returns
TRUE if successfully compiled, otherwise FALSE.

◆ RunDropScriptDragEnter()

CoreExport BOOL RunDropScriptDragEnter ( FPParams params)
Remarks
This methods takes care of the 'on droppable' handler in the current_dropscript, if supplied. If the handler returns false, the not-droppable cursor is shown.
Parameters:
FPParams* params

The set of arguments for the handler.
Returns
TRUE if droppable script will be accepted, otherwise FALSE.

◆ RunDropScriptDragOver()

CoreExport BOOL RunDropScriptDragOver ( FPParams params)
Remarks
This methods takes care of the 'on droppable' handler in the current_dropscript, if supplied, during the process of dragging contents over the drop target. If the handler returns false, the not-droppable cursor is shown.
Parameters:
FPParams* params

The set of arguments for the handler.
Returns
TRUE if droppable script will be accepted, otherwise FALSE.

◆ RunDropScriptDrop()

CoreExport BOOL RunDropScriptDrop ( FPParams params)
Remarks
This methods takes care of the 'on droppable' handler in the current_dropscript, if supplied and handles the parsing of the dropped script. If the handler returns false, the not-droppable cursor is shown.
Parameters:
FPParams* params

The set of arguments for the handler.
Returns
TRUE if droppable script will be accepted, otherwise FALSE.

◆ GetData()

CoreExport STDMETHODIMP GetData ( FORMATETC *  pFormatetc,
STGMEDIUM *  pmedium 
)

◆ GetDataHere()

CoreExport STDMETHODIMP GetDataHere ( FORMATETC *  pFormatetc,
STGMEDIUM *  pmedium 
)

◆ QueryGetData()

CoreExport STDMETHODIMP QueryGetData ( FORMATETC *  pFormatetc)

◆ InitDragDropCheck()

void InitDragDropCheck ( MacroEntry dropscript,
LPARAM  mousePt,
WPARAM  keyState,
HWND  hwnd 
)
inline
Remarks
This method will initialize a drag and drop check.
Parameters:
MacroEntry* dropscript

The drop script macro entry.

LPARAM mousePt

The initial mouse cursor position.

WPARAM keyState

They initial state of the keyboard.

HWND hwnd

The handle to the initial start window.
1171  {
1172  DropType::InitDragDropCheck(mousePt, keyState, hwnd);
1173  current_dropscript = dropscript;
1174  }
static CoreExport MacroEntry * current_dropscript
Definition: idraganddrop.h:1085
virtual CoreExport void InitDragDropCheck(LPARAM mousePt, WPARAM keyState, HWND hwnd)

◆ ReadyToDrag()

bool ReadyToDrag ( )
inlinevirtual
Remarks
This method returns TRUE if the system is ready to drag, otherwise FALSE.
Default Implementation:
{ return current_dropscript != NULL; }

Reimplemented from DropType.

1179 { return current_dropscript != NULL; }
#define NULL
Definition: autoptr.h:18

Member Data Documentation

◆ current_dropscript

CoreExport MacroEntry* current_dropscript
static