Condividi tramite


CRichEditCtrl::FormatRange

Formatta un intervallo di testo in un controllo Rich Edit per un dispositivo specifico.

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

Parametri

  • pfr
    Puntatore a una struttura FORMATRANGE contenente informazioni sul dispositivo di output.NULL indica che le informazioni memorizzate nella cache nel controllo Rich Edit possono essere rilasciati.

  • bDisplay
    Indica se il rendering del testo.Se FALSE, il testo viene misurato solo.

Valore restituito

Indice dell'ultimo carattere che ha lasciato nell'area in una.

Note

In genere, questa chiamata viene seguita da una chiamata a DisplayBand.

Per ulteriori informazioni, vedere il messaggio EM_FORMATRANGE e la struttura FORMATRANGE in Windows SDK.

Esempio

// 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();
}

Requisiti

Header: afxcmn.h

Vedere anche

Riferimenti

Classe di CRichEditCtrl

Grafico della gerarchia

CRichEditCtrl::DisplayBand