RichEdit有多页文本时也只能打印一页有关问题,贴出代码请高手帮忙

RichEdit有多页文本时也只能打印一页问题,贴出代码请高手帮忙。
BOOL CReportForm::PrintRich(const CString& Title)
{
CDC ThePrintDC; //create a device context to use
CPrintDialog PrintDialog(FALSE);  //make a print dialog too

if(PrintDialog.DoModal()==IDOK) //pressed the ok button on the print dialog?
{
ThePrintDC.Attach(PrintDialog.GetPrinterDC());//if so get settings
}
else
return FALSE; //leave this procedure, before anything bad happens
long CharRange=0;
long LastChar=0;//will store document length
DOCINFO di; //make a docinfo structure
::ZeroMemory(&di, sizeof(DOCINFO));
di.cbSize=sizeof(DOCINFO);     //set size member
di.lpszDocName="aa";//set doc name, was passed via another funtion

FORMATRANGE fr;  //format range structure
::ZeroMemory(&fr, sizeof(FORMATRANGE));
HDC hdc=ThePrintDC.GetSafeHdc();        //get handle to DC we are using
fr.hdc=hdc;                                            //Set meber in FormatRange struct
fr.hdcTarget=hdc;                //Set member in FormatRange struct
//This bit here will get all the dimentions of the printer setup
int nHorizRes = ThePrintDC.GetDeviceCaps(HORZRES),                 //width P in MM
nVertRes = ThePrintDC.GetDeviceCaps(VERTRES),        //hight in raster lines
nLogPixelsX = ThePrintDC.GetDeviceCaps(LOGPIXELSX),  //pixels per inch along x
nLogPixelsY = ThePrintDC.GetDeviceCaps(LOGPIXELSY);  //pixels per inch along y
//set the printable area of printer in the FormatRange struct
fr.rcPage.left = 0; //these 2 mean top left
fr.rcPage.top = 0;
fr.rcPage.right    = (nHorizRes/nLogPixelsX) * 1440;//these 2 mean bottom right
fr.rcPage.bottom   = (nVertRes/nLogPixelsY) * 1440;    //equation changes pixel to TWIPS
// Set up some margins all around. Make them one inch
//results vary on printers depending on setup
fr.rc.left   = fr.rcPage.left + 720;  // 1440 TWIPS = 1 inch.
fr.rc.top    = fr.rcPage.top + 720;
fr.rc.right  = fr.rcPage.right - 720;
fr.rc.bottom = fr.rcPage.bottom - 720;
//select all text for printing
CHARRANGE cr;
cr.cpMin=0;
cr.cpMax=-1;//-1 selects all
fr.chrg=cr;//set this in FormatRange struct
//get length of document, used for more than one page
CharRange=c_richedit.GetTextLength();
int ErrorStatus=0;