次の方法で共有


CRichEditCtrl::FormatRange

指定されたデバイス用にリッチ エディット コントロールのテキストの範囲を書式化します。

long FormatRange(
   FORMATRANGE* pfr,
   BOOL bDisplay = TRUE 
);

パラメーター

  • pfr
    出力デバイスの情報を含む FORMATRANGE 構造体へのポインター。 NULL を指定すると、リッチ エディット コントロール内にキャッシュされた情報を解放することを示します。

  • bDisplay
    テキストを描画するかどうかを示します。 FALSE の場合は、テキストは計測されるだけです。

戻り値

領域に入る最後の文字のインデックスに 1 を加えた値を返します。

解説

通常この関数に続いて、DisplayBand を呼び出します。

詳細については、Windows SDK の EM_FORMATRANGE メッセージと FORMATRANGE 構造体の説明を参照してください。

使用例

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

   FORMATRANGE fr;

   // Get the page width and height from the printer.
   long lPageWidth = ::MulDiv(pMyPrinterDC->GetDeviceCaps(PHYSICALWIDTH),
       1440, pMyPrinterDC->GetDeviceCaps(LOGPIXELSX));
   long lPageHeight = ::MulDiv(pMyPrinterDC->GetDeviceCaps(PHYSICALHEIGHT),
       1440, pMyPrinterDC->GetDeviceCaps(LOGPIXELSY));
   CRect rcPage(0, 0, lPageWidth, lPageHeight);

   // Format the text and render it to the printer.
   fr.hdc = pMyPrinterDC->m_hDC;
   fr.hdcTarget = pMyPrinterDC->m_hDC;
   fr.rc = rcPage;
   fr.rcPage = rcPage;
   fr.chrg.cpMin = 0;
   fr.chrg.cpMax = -1;
   m_myRichEditCtrl.FormatRange(&fr, TRUE);

   // Update the display with the new formatting.
   RECT rcClient;
   m_myRichEditCtrl.GetClientRect(&rcClient);
   m_myRichEditCtrl.DisplayBand(&rcClient);   

   pMyPrinterDC->DeleteDC();
}

必要条件

**ヘッダー:**afxcmn.h

参照

参照

CRichEditCtrl クラス

階層図

CRichEditCtrl::DisplayBand

その他の技術情報

CRichEditCtrl のメンバー