BOOL COleClientItem::SetPrintDevice(const PRINTDLG* ppd) { ASSERT(ppd == NULL || AfxIsValidAddress(ppd, sizeof(*ppd), FALSE)); DVTARGETDEVICE* ptd = NULL; if (ppd != NULL) ptd = _AfxOleCreateTargetDevice((PRINTDLG*)ppd); BOOL bResult = SetPrintDevice(ptd); CoTaskMemFree(ptd); return bResult; }
BOOL COleDocument::ApplyPrintDevice(const PRINTDLG* ppd) { ASSERT_VALID(this); ASSERT(ppd == NULL || AfxIsValidAddress(ppd, sizeof(*ppd), FALSE)); DVTARGETDEVICE* ptd = NULL; if (ppd != NULL) ptd = _AfxOleCreateTargetDevice((PRINTDLG*)ppd); BOOL bResult = ApplyPrintDevice(ptd); CoTaskMemFree(ptd); return bResult; }
DVTARGETDEVICE* AFXAPI _AfxOleCreateTargetDevice(LPPRINTDLG lpPrintDlg) { DVTARGETDEVICE* ptd=NULL; LPDEVNAMES pDN; LPDEVMODE pDM; if ((pDN = (LPDEVNAMES)GlobalLock(lpPrintDlg->hDevNames)) == NULL) return NULL; if ((pDM = (LPDEVMODE)GlobalLock(lpPrintDlg->hDevMode)) == NULL) { GlobalUnlock(lpPrintDlg->hDevNames); return NULL; } ptd = _AfxOleCreateTargetDevice(pDN, pDM); GlobalUnlock(lpPrintDlg->hDevNames); GlobalUnlock(lpPrintDlg->hDevMode); return ptd; }