DATAOBJ.H

///////////////////////////////////////////////////////////////////////////// 
// dataobj.h : IDataObject Interface to communicate data
//
// This is a part of the MMC SDK.
// Copyright (C) 1997 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// MMC SDK Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// MMC Library product.
//

#ifndef __DATAOBJ_H_
#define __DATAOBJ_H_

#include <mmc.h>

//
// Defines, Types etc...
//

typedef enum tagCOOKIETYPE
{
COOKIE_IS_ROOT,
COOKIE_IS_STATUS
} COOKIETYPE;

class CComponentData; // Forward declaration


/////////////////////////////////////////////////////////////////////////////
// CDataObject - This class is used to pass data back and forth with MMC. It
// uses a standard interface, IDataObject to acomplish this.
// Refer to OLE documentation for a description of clipboard
// formats and the IDataObject interface.

class CDataObject:
public IDataObject,
public CComObjectRoot
{
public:

// ATL Maps
DECLARE_NOT_AGGREGATABLE(CDataObject)

BEGIN_COM_MAP(CDataObject)
COM_INTERFACE_ENTRY(IDataObject)
END_COM_MAP()


CDataObject();
~CDataObject();

VOID SetCookie(ULONG ulCookie, DATA_OBJECT_TYPES Type, COOKIETYPE ct);

//
// IUnknown overrides
//

STDMETHOD(QueryInterface) (REFIID riid, LPVOID FAR* ppvObj);
STDMETHOD_(ULONG, AddRef) ();
STDMETHOD_(ULONG, Release) ();

//
// IDataObject overrides
//

STDMETHOD(GetDataHere) (FORMATETC *pformatetc,
STGMEDIUM *pmedium);


// Not Implemented
private:
STDMETHOD(GetData)(LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
{ return E_NOTIMPL; };

STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
{ return E_NOTIMPL; };

STDMETHOD(QueryGetData)(LPFORMATETC lpFormatetc)
{ return E_NOTIMPL; };

STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
{ return E_NOTIMPL; };

STDMETHOD(SetData)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
{ return E_NOTIMPL; };

STDMETHOD(DAdvise)(LPFORMATETC lpFormatetc, DWORD advf,
LPADVISESINK pAdvSink, LPDWORD pdwConnection)
{ return E_NOTIMPL; };

STDMETHOD(DUnadvise)(DWORD dwConnection)
{ return E_NOTIMPL; };

STDMETHOD(EnumDAdvise)(LPENUMSTATDATA* ppEnumAdvise)
{ return E_NOTIMPL; };

//
// Non-interface member functions
//
public:
DATA_OBJECT_TYPES GetContext() { return m_Context; }
COOKIETYPE GetCookieType() { return m_Type; }
ULONG CDataObject::GetCookie() { return m_ulCookie; }

private:
HRESULT _WriteInternal(IStream *pstm);
HRESULT _WriteDisplayName(IStream *pstm);
HRESULT _WriteNodeType(IStream *pstm);
HRESULT _WriteClsid(IStream *pstm);

ULONG m_cRefs; // object refcount
ULONG m_ulCookie; // what this obj refers to
DATA_OBJECT_TYPES m_Context; // context in which this was created
COOKIETYPE m_Type; // how to interpret _ulCookie
CComponentData *m_pcd; // NULL if created by csnapin

public:
static UINT s_cfInternal; // Our custom clipboard format
static UINT s_cfDisplayName; // Our test for a node
static UINT s_cfNodeType;
static UINT s_cfSnapinClsid;
};

#endif // __DATAOBJ_H_