Public Member Functions | Static Public Member Functions | Static Protected Attributes

DropClipFormat Class Reference

Search for all occurrences

Detailed Description

See also:
Class DropType, Class VIZableClipFmt, Class DropScriptClipFmt, DropTypes.
Description:
This class is available in release 4.0 and later only.

DropClipFormat is the base class for the various supported clipboard formats contained in a dropped IDataObject. Subclasses represent particular IDataObject clip format or module of related formats that can be accepted by various windows in 3ds Max. The prime responsibility of each is to recognize its presence in a dropped IDataObject and to parse the data object into one of the supported DropTypes. Each subclass should have a singleton instance created. This is automatically registered with the drag and drop system for use in the clipform recognition routines.
Data Members:
protected:

static Tab<DropClipFormat*> clipFmts;

The table of supported clip formats.

#include <idraganddrop.h>

Inheritance diagram for DropClipFormat:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  DropClipFormat ()
virtual bool  CheckClipFormat (IDataObject *pDataObject)
virtual DropType ParseDataObject (IDataObject *pDataObject)

Static Public Member Functions

static CoreExport DropClipFormat FindClipFormat (IDataObject *pDataObject)

Static Protected Attributes

static CoreExport Tab
< DropClipFormat * > 
clipFmts

Constructor & Destructor Documentation

DropClipFormat ( ) [inline]
Remarks:
Constructor.

Each DropClimFormat instance created is kept in the clipFmts table
{ DropClipFormat* cf = this; clipFmts.Append(1, &cf); }

Member Function Documentation

static CoreExport DropClipFormat* FindClipFormat ( IDataObject *  pDataObject ) [static]
Remarks:
This method returns a pointer to the DropClipFormat (singleton) corresponding to the clip format in the given IDataObject, or NULL if the IDataObject contains no recognizable formats. This is primarily used by the low-level default DragEnter() function in drag and drop manager.
Parameters:
IDataObject* pDataObject

The data object you wish to return the clip format for.
virtual bool CheckClipFormat ( IDataObject *  pDataObject ) [inline, virtual]
Remarks:
This method should be implemented by each subclass to detect the presence of its clipformat(s) in the given IDataObject. See ParseDataObject() below for a detailed example.
Parameters:
IDataObject* pDataObject

The data object.
Returns:
TRUE if the data was queries successfully, otherwise FALSE.
Default Implementation:
{ return false; }

Reimplemented in IDropPackageClipFmt, VIZableClipFmt, and DropScriptClipFmt.

{ return false; }
virtual DropType* ParseDataObject ( IDataObject *  pDataObject ) [inline, virtual]
Remarks:
This method should be implemented by each subclass to parse its clipformat(s) in the given IDataObject into the corresponding DropType subclass instance. For example, the DropClipFormats that accept dropped files will typically return one of the FileDropType subclasses depending on the filename suffix. A list of built-in clipformats:

IDropPackageClipFmt iDrop XML module
VIZableClipFmt VIZable file URL
DropScriptClipFmt internal dropScript

Here's an example (simplified) VIZableClipFmt implementation, which accepts a custom CF_MAXURL clip format containing the URL of a file. CheckClipFormat() returns true if it finds the CF_MAXURL clipboard format present in the given IDataObject. Because this is a dropping file, ParseDataObject() clears the current droptype data (the FileDropType::Init(), extracts the file name from the IDataObject and installs it into the FileDropType current_package variable. It then asks the FileDropType class to recognize the actual file type being dropped and return the corresponding FileDropType subclass instance (using FileDropType::FindDropType()).

    bool VIZableClipFmt::CheckClipFormat(IDataObject* pDataObject)
    {
    // accept CF_MAXURL clip formats
        FORMATETC fmt = { NULL, NULL, DVASPECT_CONTENT, -1, NULL };
        fmt.cfFormat = RegisterClipboardFormat(_M("CF_MAXURL"));
        fmt.tymed = TYMED_HGLOBAL;
        return SUCCEEDED(pDataObject->QueryGetData(&fmt)) ==
            TRUE;
    }
    
    DropType* VIZableClipFmt::ParseDataObject(IDataObject* pDataObject)
    {
    // parse a CF_MAXURL clipformat into one of the FileDropTypes
        &
    // fill in the FileDropType::current_packge URLTab
            HRESULT hr;
        FORMATETC fmt = { NULL, NULL, DVASPECT_CONTENT, -1, NULL };
        STGMEDIUM stg = { TYMED_NULL, NULL, NULL };
    
        fmt.tymed = TYMED_HGLOBAL;
        fmt.cfFormat = RegisterClipboardFormat(_M("CF_MAXURL"));
    
    // clear out the file drop current data
        FileDropType::Init();
    
    // look for CF_MAXURL formats
        hr = pDataObject->GetData(&fmt, &stg);
        if(SUCCEEDED(hr)) {
    // found, get the max file name
            MCHAR szUrl[MAX_PATH];
            ZeroMemory(szUrl, sizeof(szUrl));
            wcstombs(szUrl,
                reinterpret_cast<wchar_t*>(GlobalLock(stg.hGlobal)),
                MAX_PATH-1);
            GlobalUnlock(stg.hGlobal);
            ReleaseStgMedium(&stg);
    // add it to the current_package URLTab
            FileDropType::current_package.Add(szUrl);
        }
    
    // if we have a non-NULL module, get the appropriate
    // FileDropType (usually based on file extension), by asking the
    // utility DropType finder in FileDropType
        if (FileDropType::current_package.Count() > 0)
            return FileDropType::FindDropType(
                FileDropType::current_package[0], pDataObject);
        else
            return NULL;
    }
Parameters:
IDataObject* pDataObject

The data object.
Returns:
A pointer to the drop-type.
Default Implementation:
{ return NULL; }

Reimplemented in IDropPackageClipFmt, VIZableClipFmt, and DropScriptClipFmt.

{ return NULL; }

Member Data Documentation

CoreExport Tab<DropClipFormat*> clipFmts [static, protected]

DropClipFormat DropClipFormat DropClipFormat DropClipFormat DropClipFormat DropClipFormat DropClipFormat DropClipFormat DropClipFormat DropClipFormat
DropClipFormat DropClipFormat DropClipFormat DropClipFormat DropClipFormat DropClipFormat DropClipFormat DropClipFormat DropClipFormat DropClipFormat