本文整理汇总了C++中CDC::EndPage方法的典型用法代码示例。如果您正苦于以下问题:C++ CDC::EndPage方法的具体用法?C++ CDC::EndPage怎么用?C++ CDC::EndPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDC
的用法示例。
在下文中一共展示了CDC::EndPage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintKeyMap
//*************************************************************************************
void CBCGPKeyMapDlg::PrintKeyMap ()
{
CWaitCursor WaitCursor;
int nItem = -1;
int nFlag = (m_KeymapList.GetSelectedCount () > 0) ? LVNI_SELECTED : LVNI_ALL;
CPrintDialog dlgPrint (FALSE, PD_ALLPAGES | PD_RETURNDC | PD_NOSELECTION, NULL);
if (dlgPrint.DoModal() != IDOK)
{
return;
}
// Obtain a handle to the device context.
HDC hdcPrn = dlgPrint.GetPrinterDC ();
if (hdcPrn == NULL)
{
ASSERT (FALSE);
return;
}
CDC dc;
dc.Attach (hdcPrn);
CSize szPage (dc.GetDeviceCaps (HORZRES), dc.GetDeviceCaps (VERTRES));
dc.StartDoc(_T("BCGKeyMapDlg")); // begin a new print job
dc.StartPage ();
int nPage = 1;
int y = OnPrintHeader (dc, nPage, szPage.cx);
while ((nItem = m_KeymapList.GetNextItem (nItem, nFlag)) >= 0)
{
int nItemHeight = OnPrintItem (dc, nItem, y, szPage.cx, TRUE /* Calc height */);
if (y + nItemHeight > szPage.cy)
{
dc.EndPage();
dc.StartPage ();
y = OnPrintHeader (dc, ++nPage, szPage.cx);
}
y += OnPrintItem (dc, nItem, y, szPage.cx, FALSE /* Draw */);
}
dc.EndPage();
dc.EndDoc();
}
示例2: OnPrintAll
void ScheduleViewEx::OnPrintAll()
{
CPrintDialog dlg(FALSE);
if (IDOK == dlg.DoModal())
{
HDC dc = dlg.GetPrinterDC();
CDC DC;
DC.Attach(dc);
DEVMODE *myMode = dlg.GetDevMode();//fills myMode with printer defaults
myMode->dmOrientation = DMORIENT_LANDSCAPE;//change default to landscape
myMode->dmPrintQuality = DMRES_DRAFT;
myMode->dmColor = DMCOLOR_MONOCHROME;
DC.ResetDC(myMode);
DC.m_bPrinting = TRUE;
OnPrepareDC(&DC);
DC.StartDoc(_T("myDoc"));
int tmpOffset = m_offset;
for (int i = 0;
i< TotalPages();
i++)
{
m_offset = i;
DC.StartPage();
OnDraw(&DC);
DC.EndPage();
}
DC.EndDoc();
m_offset = tmpOffset;
}
}
示例3: EndPage
void kGUIPrintJobWin::EndPage(void)
{
if (m_pdc.EndPage ()<=0)
{
m_error=true;
m_pdc.Detach();
}
}
示例4: PrintAuto
BOOL CEdRptDoc::PrintAuto(CPrintDialog *pPntDlg)
{
// 严禁在不使用省却打印机情况下不指定打印机
ASSERT(m_bDefaultPrint || pPntDlg);
// get default print
CPrintDialog defaultDlg (FALSE, PD_RETURNDC );
AfxGetApp()->GetPrinterDeviceDefaults( &defaultDlg.m_pd );
if (!pPntDlg)
pPntDlg = &defaultDlg;
HDC hdc = pPntDlg->CreatePrinterDC();
ASSERT(hdc);
CDC dc;
dc.Attach( hdc );
dc.m_bPrinting = TRUE;
CString strTitle = m_szTitle;
if (strTitle.IsEmpty())
strTitle.LoadString(AFX_IDS_APP_TITLE);
DOCINFO di; // Initialise print doc details
memset(&di, 0, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
di.lpszDocName = strTitle;
BOOL bPrintingOK = dc.StartDoc(&di); // Begin a new print job
CPrintInfo Info;
Info.m_rectDraw.SetRect(0,0, dc.GetDeviceCaps(HORZRES), dc.GetDeviceCaps(VERTRES));
m_Grid.OnBeginPrinting(&dc, &Info); // Initialise printing
m_Grid.SetFocus();
for (UINT page = Info.GetMinPage(); page <= Info.GetMaxPage() && bPrintingOK; page++)
{
dc.StartPage(); // begin new page
Info.m_nCurPage = page;
m_Grid.OnPrint(&dc, &Info); // Print page
bPrintingOK = (dc.EndPage() > 0); // end page
}
m_Grid.OnEndPrinting(&dc, &Info); // Clean up after printing
if (bPrintingOK)
dc.EndDoc(); // end a print job
else
dc.AbortDoc(); // abort job.
dc.Detach(); // detach the printer DC
DeleteDC(hdc);
return TRUE;
}
示例5: Print
void CChartCtrl::Print(const TChartString& strTitle, CPrintDialog* pPrntDialog)
{
//AFX_MANAGE_STATE(AfxGetStaticModuleState());
CDC dc;
if (pPrntDialog == NULL)
{
CPrintDialog printDlg(FALSE);
if (printDlg.DoModal() != IDOK) // Get printer settings from user
return;
dc.Attach(printDlg.GetPrinterDC()); // attach a printer DC
}
else
dc.Attach(pPrntDialog->GetPrinterDC()); // attach a printer DC
dc.m_bPrinting = TRUE;
DOCINFO di; // Initialise print doc details
memset(&di, 0, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
di.lpszDocName = strTitle.c_str();
BOOL bPrintingOK = dc.StartDoc(&di); // Begin a new print job
CPrintInfo Info;
Info.m_rectDraw.SetRect(0,0, dc.GetDeviceCaps(HORZRES), dc.GetDeviceCaps(VERTRES));
OnBeginPrinting(&dc, &Info); // Initialise printing
for (UINT page = Info.GetMinPage(); page <= Info.GetMaxPage() && bPrintingOK; page++)
{
dc.StartPage(); // begin new page
Info.m_nCurPage = page;
OnPrint(&dc, &Info); // Print page
bPrintingOK = (dc.EndPage() > 0); // end page
}
OnEndPrinting(&dc, &Info); // Clean up after printing
if (bPrintingOK)
dc.EndDoc(); // end a print job
else
dc.AbortDoc(); // abort job.
dc.Detach(); // detach the printer DC
}
示例6: OnFilePrint
//.........这里部分代码省略.........
// Store the Handle of the Window in a temp so that it can be enabled
// once the printing is finished
CWnd * hwndTemp = AfxGetMainWnd();
hwndTemp->EnableWindow(FALSE);
CPrintingDialog dlgPrintStatus(this);
CString strTemp;
dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_DOCNAME, strTitle);
dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PRINTERNAME,
printInfo.m_pPD->GetDeviceName());
dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PORTNAME, strPortName);
dlgPrintStatus.ShowWindow(SW_SHOW);
dlgPrintStatus.UpdateWindow();
// start document printing process
if (!printInfo.m_bDocObject)
{
printInfo.m_nJobNumber = dcPrint.StartDoc(&docInfo);
if (printInfo.m_nJobNumber == SP_ERROR)
{
// enable main window before proceeding
hwndTemp->EnableWindow(TRUE);
// cleanup and show error message
OnEndPrinting(&dcPrint, &printInfo);
dlgPrintStatus.DestroyWindow();
dcPrint.Detach(); // will be cleaned up by CPrintInfo destructor
AfxMessageBox(AFX_IDP_FAILED_TO_START_PRINT);
return;
}
}
// Guarantee values are in the valid range
UINT nEndPage = printInfo.GetToPage();
UINT nStartPage = printInfo.GetFromPage();
if (nEndPage < printInfo.GetMinPage())
nEndPage = printInfo.GetMinPage();
if (nEndPage > printInfo.GetMaxPage())
nEndPage = printInfo.GetMaxPage();
if (nStartPage < printInfo.GetMinPage())
nStartPage = printInfo.GetMinPage();
if (nStartPage > printInfo.GetMaxPage())
nStartPage = printInfo.GetMaxPage();
int nStep = (nEndPage >= nStartPage) ? 1 : -1;
nEndPage = (nEndPage == 0xffff) ? 0xffff : nEndPage + nStep;
VERIFY(strTemp.LoadString(AFX_IDS_PRINTPAGENUM));
// If it's a doc object, we don't loop page-by-page
// because doc objects don't support that kind of levity.
BOOL bError = FALSE;
if (printInfo.m_bDocObject)
{
OnPrepareDC(&dcPrint, &printInfo);
OnPrint(&dcPrint, &printInfo);
}
else
{
// begin page printing loop
for (printInfo.m_nCurPage = nStartPage;
printInfo.m_nCurPage != nEndPage; printInfo.m_nCurPage += nStep)
{
示例7: OnPrint
//.........这里部分代码省略.........
OnBeginPrinting(&dcPrint, &printInfo);
if (!printInfo.m_bDocObject)
dcPrint.SetAbortProc(AbortProc);
// disable main window while printing & init printing status dialog
AfxGetMainWnd()->EnableWindow(FALSE);
CPrintingDialog dlgPrintStatus(ParentWnd);
ghwndAbort = dlgPrintStatus.m_hWnd;
CString strTemp;
dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_DOCNAME, PrintTitle);
dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PRINTERNAME,
printInfo.m_pPD->GetDeviceName());
AfxFormatString1(strTemp, nFormatID, strPortName);
dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PORTNAME, strTemp);
dlgPrintStatus.ShowWindow(SW_SHOW);
dlgPrintStatus.UpdateWindow();
// start document printing process
if (!printInfo.m_bDocObject && dcPrint.StartDoc(&docInfo) == SP_ERROR)
{
// enable main window before proceeding
AfxGetMainWnd()->EnableWindow(TRUE);
// cleanup and show error message
OnEndPrinting(&dcPrint, &printInfo);
dlgPrintStatus.DestroyWindow();
dcPrint.Detach(); // will be cleaned up by CPrintInfo destructor
AfxMessageBox(AFX_IDP_FAILED_TO_START_PRINT);
return;
}
// Guarantee values are in the valid range
UINT nEndPage = printInfo.GetToPage();
UINT nStartPage = printInfo.GetFromPage();
if (nEndPage < printInfo.GetMinPage())
nEndPage = printInfo.GetMinPage();
if (nEndPage > printInfo.GetMaxPage())
nEndPage = printInfo.GetMaxPage();
if (nStartPage < printInfo.GetMinPage())
nStartPage = printInfo.GetMinPage();
if (nStartPage > printInfo.GetMaxPage())
nStartPage = printInfo.GetMaxPage();
int nStep = (nEndPage >= nStartPage) ? 1 : -1;
nEndPage = (nEndPage == 0xffff) ? 0xffff : nEndPage + nStep;
VERIFY(strTemp.LoadString(AFX_IDS_PRINTPAGENUM));
// If it's a doc object, we don't loop page-by-page
// because doc objects don't support that kind of levity.
BOOL bError = FALSE;
// Print Loop // Burada DocObject kýsmý silindi
{
// begin page printing loop
for (printInfo.m_nCurPage = nStartPage;
printInfo.m_nCurPage != nEndPage; printInfo.m_nCurPage += nStep)
{
OnPrepareDC(&dcPrint, &printInfo);
// check for end of print
if (!printInfo.m_bContinuePrinting)
示例8: OnOptPrint
//.........这里部分代码省略.........
CDC dcPrinter;
dcPrinter.Attach(hdcPrinter);
// call StartDoc() to begin printing
DOCINFO docinfo;
memset(&docinfo, 0, sizeof(docinfo));
docinfo.cbSize = sizeof(docinfo);
docinfo.lpszDocName = "事件记录报表";
// if it fails, complain and exit gracefully
if (dcPrinter.StartDoc(&docinfo) < 0){
MessageBox("无法初始化打印机",NULL,MB_OK|MB_ICONSTOP);
}else{
dcPrinter.SetMapMode(MM_TWIPS);
CFont *pOldFont;
CFont fnt;
if(fnt.CreatePointFont(70,"宋体",&dcPrinter)){
pOldFont=(CFont*)dcPrinter.SelectObject(&fnt);
}else{
pOldFont=(CFont*)dcPrinter.SelectStockObject(DEVICE_DEFAULT_FONT);
}
CPoint pt(dcPrinter.GetDeviceCaps(HORZRES),dcPrinter.GetDeviceCaps(VERTRES));
dcPrinter.DPtoLP (&pt);
pt.y=-pt.y;
CSize sz=dcPrinter.GetTextExtent("序号 ");
CSize sz1=dcPrinter.GetTextExtent("报警时间 ");
CSize sz2=dcPrinter.GetTextExtent("变量名 ");
CSize sz3=dcPrinter.GetTextExtent("变量描述 ");
CSize sz4=dcPrinter.GetTextExtent("报警时测量值 ");
CSize sz5=dcPrinter.GetTextExtent("单位 ");
CSize sz6=dcPrinter.GetTextExtent("报警类型 ");
CSize sz7=dcPrinter.GetTextExtent("状态 ");
int lineHeight=sz.cy*1.5;
int lineCount=(pt.y-sz.cy*10)/lineHeight;
if(lineCount<0) return;
long id=0;
CString str;
int i,iPage=0;
int cLeftGap=800;
while(evtsList[id].valid){
// start a page
if (dcPrinter.StartPage() < 0){
MessageBox("无法初始化页",NULL,MB_OK|MB_ICONSTOP);
dcPrinter.AbortDoc();
}else{
// actually do some printing
//print title
iPage++;
str.Format("事件记录报表 第%2d页",iPage);
dcPrinter.TextOut(cLeftGap,-lineHeight*3,str);
//str.Format("序号 事件");
str.Format("序号");
dcPrinter.TextOut(cLeftGap,-lineHeight*5,str);
str.Format("报警时间");
dcPrinter.TextOut(cLeftGap+sz.cx,-lineHeight*5,str);
str.Format("变量名");
dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx,-lineHeight*5,str);
str.Format("变量描述");
dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx,-lineHeight*5,str);
str.Format("报警时测量值");
dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx,-lineHeight*5,str);
str.Format("单位");
dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx+sz4.cx,-lineHeight*5,str);
str.Format("报警类型");
dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx+sz4.cx+sz5.cx,-lineHeight*5,str);
str.Format("状态");
dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx+sz4.cx+sz5.cx+sz6.cx,-lineHeight*5,str);
for(i=0;i<lineCount;i++){
if(evtsList[id].valid){
CArgs args;
parse_arg_ey(evtsList[id].data, &args, ";");
str.Format("%3d",id);
dcPrinter.TextOut(cLeftGap,-lineHeight*(6+i),str);
str.Format("%s",args.argv[0]);
dcPrinter.TextOut(cLeftGap+sz.cx,-lineHeight*(6+i),str);
str.Format("%s",args.argv[2]);
dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx,-lineHeight*(6+i),str);
str.Format("%s",args.argv[1]);
dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx,-lineHeight*(6+i),str);
str.Format("%s",args.argv[6]);
dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx,-lineHeight*(6+i),str);
str.Format("%s",args.argv[7]);
dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx+sz4.cx,-lineHeight*(6+i),str);
str.Format("%s",args.argv[4]);
dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx+sz4.cx+sz5.cx,-lineHeight*(6+i),str);
str.Format("%s",args.argv[5]);
dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx+sz4.cx+sz5.cx+sz6.cx,-lineHeight*(6+i),str);
id++;
}else{
break;
}
}
}
dcPrinter.EndPage();
}
dcPrinter.SelectObject(pOldFont);
dcPrinter.EndDoc();
}
}
}