BOOL COleDocument::ApplyPrintDevice(const DVTARGETDEVICE* ptd) { ASSERT_VALID(this); ASSERT(ptd == NULL || AfxIsValidAddress(ptd, (size_t)ptd->tdSize, FALSE)); // allocate copy of target device if (ptd != NULL) { DVTARGETDEVICE* ptdNew = _AfxOleCopyTargetDevice((DVTARGETDEVICE*)ptd); if (ptdNew == NULL) return FALSE; ptd = ptdNew; } // remove old target device from memory CoTaskMemFree(m_ptd); m_ptd = (DVTARGETDEVICE*)ptd; // Note: updating all the client items does not refresh the pres. cache POSITION pos = GetStartPosition(); COleClientItem* pItem; while ((pItem = GetNextClientItem(pos)) != NULL) { // update all the client items with new target device pItem->SetPrintDevice(ptd); } return TRUE; }
void AFXAPI _AfxOleCopyFormatEtc(LPFORMATETC petcDest, LPFORMATETC petcSrc) { ASSERT(petcDest != NULL); ASSERT(petcSrc != NULL); petcDest->cfFormat = petcSrc->cfFormat; petcDest->ptd = _AfxOleCopyTargetDevice(petcSrc->ptd); petcDest->dwAspect = petcSrc->dwAspect; petcDest->lindex = petcSrc->lindex; petcDest->tymed = petcSrc->tymed; }