Beispiel #1
0
//
//	Constructor 
//
CEnumFormatEtc::CEnumFormatEtc(FORMATETC *pFormatEtc, int nNumFormats)
{
	m_lRefCount = 1;
	m_nIndex = 0;
	m_nNumFormats = nNumFormats;
	m_pFormatEtc = new FORMATETC[nNumFormats];

	// copy the FORMATETC structures
	for (int i = 0; i < nNumFormats; i++) {
		DeepCopyFormatEtc(&m_pFormatEtc[i], &pFormatEtc[i]);
	}
}
DragEnumFormatEtc::DragEnumFormatEtc(FORMATETC* pFormatEtc, int nNumFormats) {
  AddRef();

  m_nIndex = 0;
  m_nNumFormats = nNumFormats;
  m_pFormatEtc = new FORMATETC[nNumFormats];

  // make a new copy of each FORMATETC structure
  for (int i = 0; i < nNumFormats; i++) {
    DeepCopyFormatEtc(&m_pFormatEtc[i], &pFormatEtc[i]);
  }
}
Beispiel #3
0
//
//	Constructor
//
CEnumFormatEtc::CEnumFormatEtc(FORMATETC *pFormatEtc, int nNumFormats)
{
	m_lRefCount   = 1;
	m_nIndex      = 0;
	m_nNumFormats = nNumFormats;
	m_pFormatEtc  = nNumFormats ? (FORMATETC*)calloc(nNumFormats, sizeof(FORMATETC)) : NULL;

	// copy the FORMATETC structures
	for (int i = 0; i < nNumFormats; i++)
	{
		DeepCopyFormatEtc(&m_pFormatEtc[i], &pFormatEtc[i]);
	}
}
Beispiel #4
0
HRESULT CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pceltFetched)
{
	ULONG copied = 0;
	// copy the FORMATETC structures into the caller's buffer
	while (m_nIndex < m_nNumFormats && copied < celt) 
	{
		DeepCopyFormatEtc(&pFormatEtc [copied], &m_pFormatEtc [m_nIndex]);
		copied++;
		m_nIndex++;
	}
	// store result
	if(pceltFetched != 0) 
		*pceltFetched = copied;
	// did we copy all that was requested?
	return (copied == celt) ? S_OK : S_FALSE;
}
Beispiel #5
0
//
//	IEnumFORMATETC::Next
//
//	If the returned FORMATETC structure contains a non-null "ptd" member, then
//  the caller must free this using CoTaskMemFree (stated in the COM documentation)
//
HRESULT __stdcall CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG * pceltFetched)
{
	ULONG copied = 0;

	// validate arguments
	if (celt == 0 || pFormatEtc == 0)
		return E_INVALIDARG;

	// copy FORMATETC structures into caller's buffer
	while (m_nIndex < m_nNumFormats && copied < celt) {
		DeepCopyFormatEtc(&pFormatEtc[copied], &m_pFormatEtc[m_nIndex]);
		copied++;
		m_nIndex++;
	}

	// store result
	if (pceltFetched != 0)
		*pceltFetched = copied;

	// did we copy all that was requested?
	return (copied == celt) ? S_OK : S_FALSE;
}