Click here to Skip to main content
15,895,667 members
Articles / Programming Languages / C++

Tips in Writing Namespace Extension (III) - Drag and Drop objects between System Namespace and your NSE

Rate me:
Please Sign up or sign in to vote.
4.73/5 (19 votes)
22 Feb 200617 min read 240.5K   2.1K   56  
An article on implementing drag and drop operation between your NSE and system namespace.
#if !defined(AFX_ENUMFORMATETC_H__20041129_075F_904E_7D1B_0080AD509054__INCLUDED_)
#define AFX_ENUMFORMATETC_H__20041129_075F_904E_7D1B_0080AD509054__INCLUDED_

#pragma once


/////////////////////////////////////////////////////////////////////////////
// CEnumFORMATETC

class ATL_NO_VTABLE CNSFEnumFmtEtc : 
   public CComObjectRootEx<CComSingleThreadModel>, 
   public IEnumFORMATETC
{
public:
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CNSFEnumFmtEtc)
   COM_INTERFACE_ENTRY(IEnumFORMATETC)
END_COM_MAP()

	ULONG m_dwEnumPos;

    HRESULT FinalConstruct()
    { 
		m_dwEnumPos=0;
		return S_OK;
	}

	void FinalRelease()
	{
	}  

   // IEnumFORMATETC

   STDMETHOD(Next)(ULONG, LPFORMATETC pFormatetc, ULONG *pdwCopied)
   {
      VALIDATE_POINTER(pFormatetc);

      if( pdwCopied!=NULL ) 
		  *pdwCopied = 1L;
      m_dwEnumPos++;

      switch( m_dwEnumPos ) 
	  {
      case 1:
         pFormatetc->cfFormat = _Module.m_CFSTR_NSEDRAGDROP;
         pFormatetc->ptd = NULL;
         pFormatetc->dwAspect = DVASPECT_CONTENT;
         pFormatetc->lindex = -1;
         pFormatetc->tymed = TYMED_HGLOBAL;
         break;
      case 2:
         pFormatetc->cfFormat = CF_HDROP;
         pFormatetc->ptd = NULL;
         pFormatetc->dwAspect = DVASPECT_CONTENT;
         pFormatetc->lindex = -1;
         pFormatetc->tymed = TYMED_HGLOBAL;
         break;
      default:
         if( pdwCopied!=NULL ) 
			 *pdwCopied = 0L;
         return S_FALSE;
      }      
      return S_OK;
   }

   STDMETHOD(Skip)(ULONG n)
   {
      m_dwEnumPos += n;
      return S_OK;
   }

   STDMETHOD(Reset)(void)
   {
      m_dwEnumPos = 0L;
      return S_OK;
   }

   STDMETHOD(Clone)(LPENUMFORMATETC*)
   {
      ATLTRACENOTIMPL(_T("CNSFEnumFmtEtc::Clone"));
   }
   
};


#endif // !defined(AFX_ENUMFORMATETC_H__20041129_075F_904E_7D1B_0080AD509054__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
China China
ZengXi is a SOHO guy. Her expertise includes ATL, COM, Web Service, XML, Database Systems and Information Security Technology. Now she is interested in Instant Messages softwares. She also enjoys her hobbies of reading books, listening music and watching cartoons.

Comments and Discussions