共用方式為


CRichEditCtrl::SetTargetDevice

設定用來 WYSIWYG (所看到所取得) 格式化和線條寬度的目標裝置適用於此 CRichEditCtrl 物件。

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

參數

  • hDC
    檔案名稱、裝置內容的控制代碼新的目標裝置的。

  • lLineWidth
    使用的線條寬度) 進行格式化。

  • dc
    新的目標裝置的CDC

傳回值

如果不是零,則成功,則為,否則為 0。

備註

如果函式成功, Rich Edit 控制項擁有做為參數傳遞的裝置內容。 在這種情況下,呼叫函式不應終結裝置內容。

如需詳細資訊,請參閱 Windows SDK的 EM_SETTARGETDEVICE

範例

// 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 類別

階層架構圖表

CRichEditCtrl::FormatRange

CRichEditCtrl::DisplayBand