Поделиться через


CRichEditCtrl::SetTargetDevice

Sets the target device and line width used for WYSIWYG (what you see is what you get) formatting in this CRichEditCtrl object.

BOOL SetTargetDevice(
   HDC hDC,
   long lLineWidth 
);
BOOL SetTargetDevice(
   CDC& dc,
   long lLineWidth 
);

Параметры

  • hDC
    Handle to the device context for the new target device.

  • lLineWidth
    Line width to use for formatting.

  • dc
    CDC for the new target device.

Возвращаемое значение

Nonzero if successful; otherwise, 0.

Заметки

If this function is successful, the rich edit control owns the device context passed as a parameter. In that case, the calling function should not destroy the device context.

For more information, see EM_SETTARGETDEVICE in the Windows SDK.

Пример

// First obtain a pointer to a printer DC.
CPageSetupDialog psDlg;
if (IDOK == psDlg.DoModal())
{
   CDC* pMyPrinterDC = CDC::FromHandle(psDlg.CreatePrinterDC());

   // Get line width information from the printer.
   long lLineWidth = ::MulDiv(pMyPrinterDC->GetDeviceCaps(PHYSICALWIDTH),
       1440, pMyPrinterDC->GetDeviceCaps(LOGPIXELSX));

   // Set the printer as the target device.
   m_myRichEditCtrl.SetTargetDevice(*pMyPrinterDC, lLineWidth);   

   pMyPrinterDC->DeleteDC();
}

Требования

Header: afxcmn.h

См. также

Основные понятия

CRichEditCtrl Class

CRichEditCtrl Members

Hierarchy Chart

CRichEditCtrl::FormatRange

CRichEditCtrl::DisplayBand