Share via


CRichEditCtrl::FormatRange

Da formato a un intervalo de texto en un control rich edit para un dispositivo concreto.

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

Parámetros

  • pfr
    Puntero a la estructura de FORMATRANGE que contiene información del dispositivo de salida.NULL indica que la información almacenada en caché dentro del control rich edit puede ser liberado.

  • bDisplay
    Indica si se representa el texto.Si FALSO, el texto solo se mide.

Valor devuelto

El índice del último carácter que quepa en el área más uno.

Comentarios

Normalmente, esta llamada es seguida de una llamada a DisplayBand.

Para obtener más información, vea el mensaje de EM_FORMATRANGE y la estructura de FORMATRANGE en Windows SDK.

Ejemplo

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

Requisitos

encabezado: afxcmn.h

Vea también

Referencia

Clase de CRichEditCtrl

Gráfico de jerarquía

CRichEditCtrl::DisplayBand