Compartilhar via


CRichEditCtrl::FormatRange

Formata um intervalo de texto em uma rica controle de edição para um dispositivo específico.

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

Parâmetros

  • PFR
    Ponteiro para o FORMATRANGE estrutura que contém informações sobre o dispositivo de saída.NULO indica que as informações armazenadas em cache dentro de um controle rich edição podem ser liberadas.

  • bDisplay
    Indica se o texto deve ser processado.If FALSE, o texto é medido apenas.

Valor de retorno

O índice do último caractere que se encaixa na região de mais de um.

Comentários

Normalmente, essa telefonar é seguida por uma telefonar para DisplayBand.

Para obter mais informações, consulte EM_FORMATRANGE mensagem de e FORMATRANGE estrutura o Windows SDK.

Exemplo

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

Cabeçalho: afxcmn.h

Consulte também

Referência

Classe CRichEditCtrl

Gráfico de hierarquia

CRichEditCtrl::DisplayBand

Outros recursos

CRichEditCtrl membros