Public Member Functions

IDropPackageClipFmt Class Reference

Search for all occurrences

Detailed Description

See also:
Class DropClipFormat

Description:
This class is available in release 4.0 and later only.

This class represents the iDrop XML module.

#include <idraganddrop.h>

Inheritance diagram for IDropPackageClipFmt:
Inheritance graph
[legend]

List of all members.

Public Member Functions

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

Member Function Documentation

bool CheckClipFormat ( IDataObject *  pDataObject ) [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 from DropClipFormat.

DropType* ParseDataObject ( IDataObject *  pDataObject ) [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 from DropClipFormat.


IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt
IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt IDropPackageClipFmt