예제 #1
0
/*+/csubr/TOC----------------------------------------------------------------
* PlPrtClose - close a print job for a Windows printer
*
* Purpose:
*		Closes a print job for a Windows printer.  "end page" and "end
*		document" commands are sent to the printer.
*
*		After closing the print job, this routine wraps up operations
*		for the PL_CTX for the printout.
*
* Return Value:
*		PL_OK, or
*		PL_PRT_CANCEL  if bAbort is 1 or if PlPrtStatusWindow has been
*					called and the operator clicks Cancel, or
*		other codes for other errors
*
* Notes:
* 1.	If bAbort is 1 (or if pPlot->bPrintCancel is 1), then the printout
*		is aborted, so that nothing is sent to the printer.
* 2.	This routine automatically calls PlotWrapup.
*
* See Also:
*		PlPrtOpenDefault, PlPrtOpenDialog, PlPrtStatusWindow
*
*-Date     Author		Revision
* -------- ------------	--------
* 06-08-95 R. Cole		created
*--------------------------------------------------------------------------*/
int PASCAL
PlPrtClose(
PL_CTX	*pPlot,			// IO pointer to plot context struct for printing
int		bAbort)			// I 1 to abort the printout
{
	int		retStat=PL_OK;
	int		stat;
	PRINTDLG *pPd=NULL;

	if (pPlot->hDC != 0) {
		if (bAbort || pPlot->bPrintCancel)
			stat = AbortDoc(pPlot->hDC);
		else {
			stat = EndPage(pPlot->hDC);
			stat = EndDoc(pPlot->hDC);
		}
	}
	if (pPlot->pPd != NULL) {
		pPd = (PRINTDLG *)pPlot->pPd;
		if (pPd->hDevMode != 0) GlobalFree(pPd->hDevMode);
		if (pPd->hDevNames != 0) GlobalFree(pPd->hDevNames);
		GlobalUnlock(pPlot->hPD);
	}
	if (pPlot->hPD != 0) GlobalFree(pPlot->hPD);
	if (pPlot->hDC != 0) DeleteDC(pPlot->hDC);
	pPlot->hDC = 0;
	pPlot->hPD = 0;
	pPlot->pPd = NULL;

	retStat = PlPlotWrapup(pPlot);
	strcpy(pPlot->szPrintOpen, "cls");

	return retStat;
}
예제 #2
0
파일: WinPrint.cpp 프로젝트: aminsyed/rulib
void CWinPrint::Destroy()
{
	// End page
	EndPage();

	// End printing
	EndDoc();

	// Delete the print dc
	if ( m_pd.hDC ) DeleteDC( m_pd.hDC );

	ZeroMemory( &m_pd, sizeof( m_pd ) );

#if defined ( RULIB_USE_PRINTDLG )

	if ( m_pdx.hDC ) DeleteDC( m_pdx.hDC );

	ZeroMemory( &m_pdx, sizeof( m_pdx ) );

#endif

	ZeroMemory( &m_psd, sizeof( m_psd ) );

	ZeroMemory( &m_rect, sizeof( m_rect ) );
}
예제 #3
0
파일: map.cpp 프로젝트: pjwolfe41/MackOil
void endPrint()
{
    EndPage(pdfDC);
    EndDoc(pdfDC);

    DeleteDC(pdfDC);
}
예제 #4
0
파일: OSiSP1.cpp 프로젝트: LisP94/OSiSP
void Print(HWND hWnd)
{
	PRINTDLG PrintDialog;
	memset(&PrintDialog, 0, sizeof(PRINTDLG));
	PrintDialog.lStructSize = sizeof(PRINTDLG);
	PrintDialog.hwndOwner = hWnd;
	PrintDialog.hDevMode = NULL;
	PrintDialog.hDevNames = NULL;
	PrintDialog.nCopies = 1;
	PrintDialog.Flags = PD_RETURNDC;
	PrintDialog.nMinPage = 1;
	PrintDialog.nMaxPage = 0xFFFF;
	PrintDlg(&PrintDialog);
	DOCINFO docInfo;
	docInfo.cbSize = sizeof(docInfo);
	docInfo.lpszDocName = L"Printing";
	docInfo.lpszOutput = 0;
	docInfo.lpszDatatype = 0;
	docInfo.fwType = 0;
	StartDoc(PrintDialog.hDC, &docInfo); 
	RECT printRect;
	GetClientRect(hWnd, &printRect);
	StretchBlt(PrintDialog.hDC, 0, 0, scrhor*4, scrvert*4, hdc1, scrhor/3, scrvert/3, scrhor/3*2,scrvert/3*2, SRCCOPY);
	EndDoc(PrintDialog.hDC);
}
예제 #5
0
main ()
{
	PRINTDLG	pd;
	DOCINFO		di;
	char*		szMessage;

	memset (&pd, 0, sizeof(PRINTDLG));
	memset (&di, 0, sizeof(DOCINFO));

	di.cbSize = sizeof(DOCINFO);
	di.lpszDocName = "Test";

	pd.lStructSize = sizeof(PRINTDLG);
	pd.Flags = PD_PAGENUMS | PD_RETURNDC;
	pd.nFromPage = 1;
	pd.nToPage = 1;
	pd.nMinPage = 1;
	pd.nMaxPage = 1;

	szMessage = 0;

	if (PrintDlg (&pd))
	{
		if (pd.hDC)
		{
			if (StartDoc (pd.hDC, &di) != SP_ERROR)
			{
				StartPage (pd.hDC);

				TextOut (pd.hDC, 0, 0, "Hello, printer!", 15);

				EndPage (pd.hDC);

				EndDoc (pd.hDC);

				szMessage = "Printed.";
			}
			else
			{
				szMessage = "Could not start document.";
			}
		}
		else
		{
			szMessage = "Could not create device context.";
		}
	}
	else
	{
		szMessage = "Canceled or printer could not be setup.";
	}

	if (szMessage)
	{
		MessageBox (NULL, szMessage, "Print Test", MB_OK);
	}

	return 0;
}
예제 #6
0
void Print::endprint(HWND ohwnd) {                //put the hwnd here

    EndDoc(printdlg.hDC);
    DeleteDC(memDC);
    DeleteDC(printer_mem_dc);
    DeleteDC(printdlg.hDC);
    ReleaseDC(ohwnd, hdc);
}
예제 #7
0
파일: cprinter_121.c 프로젝트: ygmpkk/house
void endDoc(int hdc)
{
	//rMessageBox(NULL, MB_APPLMODAL, "in endDoc", "");
	if (bUserAbort)
		AbortDoc((HDC) hdc);
	  else
		EndDoc((HDC) hdc);
}
예제 #8
0
파일: Fl_Gdi.cpp 프로젝트: GustavoMOG/efltk
Fl_Gdi::~Fl_Gdi()
{
    if(nPages)
        EndPage(gc_);
    EndDoc(gc_);
    DeleteDC(gc_);
    if(delete_mode_) GlobalFree(mode_);
}
예제 #9
0
파일: printer.c 프로젝트: Bgods/r-source
/*
 *  Internal printer deletion function.
 */
static void private_delprinter(printer obj)
{
    HDC h = (HDC) obj->handle;
    if (!obj || !h || (obj->kind != PrinterObject)) return;
    EndPage(h);
    EndDoc(h);
    DeleteDC(h);
    return;
}
예제 #10
0
void CComPrint::PrintBmp(UINT nBmpId)
{
	char szPrinter[200] = "";
	char *pszDevice = NULL;
	char *pszDriver = NULL;
	char *pszOutput = NULL;

	HDC hdcPrint = NULL; // 定义一个设备环境句柄

	static DOCINFO di={sizeof(DOCINFO),"printer",NULL};

	// 得到设备字符串存入数组szPrinter中
	GetProfileString("windows","device",",,,",szPrinter,80); 

	// 将设备字符串分解
	if( (NULL != (pszDevice = strtok(szPrinter,","))) && 
		(NULL != (pszDriver = strtok(NULL,","))) &&
		(NULL != (pszOutput = strtok(NULL,","))))
	{
		// 创建一个打印机设备句柄
		if((hdcPrint = CreateDC(pszDriver,pszDevice, pszOutput, NULL)) != 0)
		{ 
			if (StartDoc(hdcPrint, &di) > 0)	//开始执行一个打印作业 
			{ 
				StartPage(hdcPrint);			//打印机走纸,开始打印 
				SaveDC(hdcPrint);				//保存打印机设备句柄

				#pragma warning(disable:4312)

				// 输出图片
				HBITMAP hBitmap=::LoadBitmap(AfxGetInstanceHandle(),(LPCTSTR)nBmpId);
				BITMAP bitmap;
				::GetObject(hBitmap,sizeof(BITMAP),&bitmap);

				#pragma warning(default:4312)

				HDC dcMem;
				dcMem=::CreateCompatibleDC(hdcPrint);
				HBITMAP hOldBmp=(HBITMAP)::SelectObject(dcMem,hBitmap);

				int nVertCenterPos = ::GetDeviceCaps(hdcPrint, VERTRES) / 2;
				::StretchBlt(hdcPrint,1,50,400,bitmap.bmHeight,dcMem,0,0,bitmap.bmWidth,bitmap.bmHeight,SRCCOPY);

				::SelectObject(dcMem,hOldBmp);
				::DeleteDC(dcMem);
				::DeleteObject(hBitmap);

				RestoreDC(hdcPrint,-1); //恢复打印机设备句柄 
				EndPage(hdcPrint); //打印机停纸,停止打印 
				EndDoc(hdcPrint); //结束一个打印作业 
			} 

			// 用API函数DeleteDC销毁一个打印机设备句柄 
			DeleteDC(hdcPrint);
		}
	}
}
예제 #11
0
파일: kguimingw.cpp 프로젝트: CarlHuff/kgui
/* false=error, true=ok */
bool kGUIPrintJobMINGW::End(void)
{
	if(m_error==true) /* some error occured previously, abort */
        AbortDoc (m_printerHDC);
	else
		EndDoc (m_printerHDC);

	return(!m_error);
}
예제 #12
0
파일: print.cpp 프로젝트: hzwjava/ORDER
int finishDocument(const int pdcID) {
    HDC pdc = printerDCs[pdcID];
    if (pdc != NULL) {
        if (EndDoc(pdc) > 0) {
            releasePrinterDC(pdcID);
            return JNI_TRUE;
        }
    }
    return JNI_FALSE;
}
예제 #13
0
파일: gdi_print.c 프로젝트: Oxyoptia/x3270
/*
 * Clean up the GDI data structures without attempting any more printing.
 */
static void
gdi_abort(void)
{
    if (pstate.out_row) {
	(void) EndPage(pstate.dlg.hDC);
	pstate.out_row = 0;
    }
    (void) EndDoc(pstate.dlg.hDC);

    cleanup_fonts();
}
예제 #14
0
bool CPrinterDC::End(void)
{
	ASSERT(m_hDC);

	m_iLastError = EndDoc(m_hDC);

	// Error occurred?
	if (m_iLastError < 0)
		return FALSE;
	
	return TRUE;
}
예제 #15
0
/* 
%F cdKillCanvas para Printer.
Termina a pagina e termina o documento, enviando-o para a impressora.
*/
static void cdkillcanvas (cdCtxCanvas *ctxcanvas)
{
  EndPage(ctxcanvas->hDC);
  EndDoc(ctxcanvas->hDC);
  
  cdwKillCanvas(ctxcanvas);
  
  DeleteDC(ctxcanvas->hDC);
  
  memset(ctxcanvas, 0, sizeof(cdCtxCanvas));
  free(ctxcanvas);
}
예제 #16
0
파일: cdwprnp.cpp 프로젝트: LuaDist/cd
/* 
%F cdKillCanvas para Printer.
Termina a pagina e termina o documento, enviando-o para a impressora.
*/
static void cdkillcanvas (cdCtxCanvas* ctxcanvas)
{
  cdwpKillCanvas(ctxcanvas);
  
  EndPage(ctxcanvas->hDC);
  EndDoc(ctxcanvas->hDC);

  ClosePrinter(ctxcanvas->printerHandle);
  DeleteDC(ctxcanvas->hDC);
  
  delete ctxcanvas;
}
예제 #17
0
void Editor::print(){

	static const int MARG=720;	//1440=1 inch

	CPrintDialog dlg(false);
	int e=dlg.DoModal();if( e==IDCANCEL ) return;

	HDC hdc=dlg.GetPrinterDC();
	if( !hdc ){
		MessageBox( "Error printing" );
		return;
	}

	int hr=GetDeviceCaps(hdc,HORZRES),vr=GetDeviceCaps(hdc,VERTRES);
	int px=GetDeviceCaps(hdc,LOGPIXELSX),py=GetDeviceCaps(hdc,LOGPIXELSY);

	SetMapMode(hdc,MM_TEXT);

	FORMATRANGE fr={0};
	fr.hdc=fr.hdcTarget=hdc;
	fr.rcPage.left=fr.rcPage.top=0;
	fr.rcPage.right=(hr/px)*1440;
	fr.rcPage.bottom=(vr/py)*1440;

	//margins
	fr.rc.left=fr.rcPage.left+MARG;
	fr.rc.top=fr.rcPage.top+MARG;
	fr.rc.right=fr.rcPage.right-MARG;
	fr.rc.bottom=fr.rcPage.bottom-MARG;

	char buff[MAX_PATH];
	strcpy( buff,name.c_str() );

	DOCINFO di={sizeof(di)};
	di.lpszDocName=buff;

	getSel();
	int start=selStart,end=selEnd;
	if( start==end ){ start=0;end=editCtrl.GetTextLength(); }

	StartDoc(hdc,&di);
	while( start<end ){
		StartPage(hdc);
		fr.chrg.cpMin=start;
		fr.chrg.cpMax=end;
		start=editCtrl.FormatRange(&fr,true);
		EndPage(hdc);
	}
	EndDoc(hdc);

	editCtrl.FormatRange(0,false);
	DeleteDC(hdc);
}
예제 #18
0
void SimplePrint(int nPages)
{
	TCHAR temp[MAX_PATH];

	DWORD size = MAX_PATH;
	GetDefaultPrinter(temp, & size); // default printer name

	HDC hDC = CreateDC(NULL, temp, NULL, NULL); // DC with default setting
	
	if ( hDC )
	{
		nCall_AbortProc = 0;
		SetAbortProc(hDC, SimpleAbortProc);

		DOCINFO docinfo;
		docinfo.cbSize       = sizeof(docinfo);
		docinfo.lpszDocName  = _T("SimplePrint");
		docinfo.lpszOutput   = NULL; 
		docinfo.lpszDatatype = _T("EMF");
		docinfo.fwType		 = 0; 

		if ( StartDoc(hDC, & docinfo) > 0 )
		{
			for (int p=0; p<nPages; p++) // one page at a time
				if ( StartPage(hDC) <= 0 )
					break;
				else
				{
					int width  = GetDeviceCaps(hDC, HORZRES);
					int height = GetDeviceCaps(hDC, VERTRES);
					int dpix   = GetDeviceCaps(hDC, LOGPIXELSX);
					int dpiy   = GetDeviceCaps(hDC, LOGPIXELSY);
			
					wsprintf(temp, _T("Page %d of %d"), p+1, nPages);
					SetTextAlign(hDC, TA_TOP | TA_RIGHT );
					TextOut(hDC, width, 0, temp, _tcslen(temp));

					Rectangle(hDC, 0, 0, dpix, dpiy);
					Rectangle(hDC, width, height, width-dpix, height-dpiy);
				
					if ( EndPage(hDC)<0 )
						break;
				}
			
			EndDoc(hDC);
		}

		DeleteDC(hDC);
	}

	wsprintf(temp, "AbortProc called %d times", nCall_AbortProc);
	MessageBox(NULL, temp, "SimlePrint", MB_OK);	
}
예제 #19
0
파일: Printer.cpp 프로젝트: Unitrunker/Tile
static bool print(ITile *pDraw)
{
	PRINTDLG pd = {0};
	pd.lStructSize = sizeof pd;

	/* 
	 * get rid of PD_RETURNDEFAULT on the line below if you'd like to
	 * see the "Printer Settings" dialog!
	 *
	 */
	pd.Flags = PD_RETURNDEFAULT | PD_RETURNDC;

	// try to retrieve the printer DC
	if( !PrintDlg(&pd) )
	{
		return false;
	}

	DOCINFO di = {0};
	HDC hPrinter = pd.hDC;

	// initialization of the printing!

	// start the first and only page

	Printer canvas(hPrinter);

	RECT rect = {0};
	canvas.GetClipBox(&rect);
	Tiles::rect_t wrect;
	wrect.x = rect.left;
	wrect.y = rect.top;
	wrect.wide = rect.right - rect.left;
	wrect.high = rect.bottom - rect.top;
	pDraw->setRect(wrect);

	pDraw->Draw(&canvas, false);

	// uncomment the following line to print in colour! :)
	// SetTextColor( hPrinter, 0x0000FF );

	// finish the first page
	EndPage( hPrinter );

	// end this document and release the printer's DC
	EndDoc( hPrinter );
	//DeleteDC( hPrinter );
	return true;
}
예제 #20
0
/******************************************************************
 *                  EndPage  [GDI32.@]
 *
 */
INT WINAPI EndPage(HDC hdc)
{
    INT ret = 0;
    DC *dc = DC_GetDCPtr( hdc );
    if(!dc) return SP_ERROR;

    if (dc->funcs->pEndPage) ret = dc->funcs->pEndPage( dc );
    GDI_ReleaseObj( hdc );
    if (!QueryAbort16( hdc, 0 ))
    {
        EndDoc( hdc );
        ret = 0;
    }
    return ret;
}
예제 #21
0
/******************************************************************
 *                  EndPage  [GDI32.@]
 *
 */
INT WINAPI EndPage(HDC hdc)
{
    INT ret = 0;
    DC *dc = get_dc_ptr( hdc );
    if(!dc) return SP_ERROR;

    if (dc->funcs->pEndPage) ret = dc->funcs->pEndPage( dc->physDev );
    if (dc->pAbortProc && !dc->pAbortProc( hdc, 0 ))
    {
        EndDoc( hdc );
        ret = 0;
    }
    release_dc_ptr( dc );
    return ret;
}
예제 #22
0
파일: print.c 프로젝트: ErisBlastar/osfree
/*****************************************************************************
 End document
 Done on PRINT CLOSE
*****************************************************************************/
static void EndDocument(void)
{
   DeleteObject( SelectObject( pd.hDC, hOldFont ) );
   if (defaultprinter)
   {
     EndPage( pd.hDC );
     EndDoc( pd.hDC );
   }
   else
   {
     EndPagePrinter( hPrinter );
     EndDocPrinter( hPrinter );
   }
   documentON = FALSE;
}
예제 #23
0
파일: GPrintDC.cpp 프로젝트: FEI17N/Lgi
GPrintDC::~GPrintDC()
{
	// EndPage();

    if (hDC)
    {
		if (d->DocOpen)
		{
			EndDoc(hDC);
		}

	    DeleteDC(hDC);
		hDC = 0;
    }
}
예제 #24
0
void MacPrinterCanvas::finish() {
	if (!hdc) {return;}
	endPaint();
	//if (!Escape(hdc, NEWFRAME, 0, NULL, NULL)) {
		//DebugMessage("NEWFRAME failed\n");
	//	abort();
	//}
	//if (!Escape(hdc, ENDDOC, 0, NULL, NULL)) {
		//DebugMessage("ENDDOC failed\n");
	//	abort();
	//}
	EndPage(hdc);
	EndDoc(hdc);
	DeleteDC(hdc);
	hdc = 0;
}
예제 #25
0
int GPdestroywidget (Gwidget_t *widget) {
    HENHMETAFILE mfile;

    if (WPU->mode == 1) {
        mfile = CloseEnhMetaFile (GC);
        OpenClipboard (NULL);
        EmptyClipboard ();
        SetClipboardData (CF_ENHMETAFILE, mfile);
        CloseClipboard ();
        DeleteMetaFile (mfile);
    } else {
        EndPage (GC);
        EndDoc (GC);
    }
    return 0;
}
예제 #26
0
파일: dev.c 프로젝트: Absolight/Prima
Bool
apc_prn_end_doc( Handle self)
{
   apcErrClear;

   objCheck false;
   if ( EndPage( sys ps) < 0) apiPrnErr;
   if ( EndDoc ( sys ps) < 0) apiPrnErr;

   hwnd_leave_paint( self);
   if ( sys pal) DeleteObject( sys pal);
   DeleteDC( sys ps);
   sys pal = nil;
   sys ps = nil;
   return apcError == errOk;
}
예제 #27
0
파일: mswprint.c 프로젝트: sharkcz/xtrkcad
void wPrintDocEnd( void )
{
	if (!printStatus)
		return;
	EndDoc( printDlg.hDC );
	if ( newPrintPalette ) {
		SelectPalette( printDlg.hDC, oldPrintPalette, 0 );
		DeleteObject( newPrintPalette );
		newPrintPalette = (HPALETTE)0;
	}
		
	EnableWindow( mswHWnd, TRUE );
	DestroyWindow( hAbortDlgWnd );
	FreeProcInstance( lpAbortDlg );
	FreeProcInstance( lpAbortProc );
	DeleteDC( printDlg.hDC );
	printStatus = FALSE;
}
예제 #28
0
void CComPrint::WinPrint(CString csText)
{
	char szPrinter[200] = "";
	char *pszDevice = NULL;
	char *pszDriver = NULL;
	char *pszOutput = NULL;

	HDC hdcPrint = NULL; // 定义一个设备环境句柄

	static DOCINFO di={sizeof(DOCINFO),"printer",NULL};

	// 得到设备字符串存入数组szPrinter中
	GetProfileString("windows","device",",,,",szPrinter,80); 

	// 将设备字符串分解
	if( (NULL != (pszDevice = strtok(szPrinter,","))) && 
		(NULL != (pszDriver = strtok(NULL,","))) &&
		(NULL != (pszOutput = strtok(NULL,","))))
	{
		// 创建一个打印机设备句柄
		if((hdcPrint = CreateDC(pszDriver,pszDevice, pszOutput, NULL)) != 0)
		{ 
			if (StartDoc(hdcPrint, &di) > 0)	//开始执行一个打印作业 
			{ 
				StartPage(hdcPrint);			//打印机走纸,开始打印 
				SaveDC(hdcPrint);				//保存打印机设备句柄

				// 输出文字
				CRect rcText(0,0,0,0);
				::DrawText(hdcPrint, csText, csText.GetLength(), &rcText, DT_CALCRECT);	// 计算大小
				::DrawText(hdcPrint, csText, csText.GetLength(), &rcText, DT_WORDBREAK);

				RestoreDC(hdcPrint,-1);			//恢复打印机设备句柄 
				EndPage(hdcPrint);				//打印机停纸,停止打印 
				EndDoc(hdcPrint);				//结束一个打印作业 
			} 

			// 用API函数DeleteDC销毁一个打印机设备句柄 
			DeleteDC(hdcPrint);
		}
	}
}
예제 #29
0
void EndPrinting ( void )
{
	if ( pd.hDC )
	{
		int nError = EndPage(pd.hDC); 
		if (nError <= 0)
		{
			DeleteDC ( pd.hDC ); 
			pd.hDC = NULL;
			return;
		}

		// end printing
		EndDoc(pd.hDC);

		// Delete DC when done.
		DeleteDC ( pd.hDC ); 
		pd.hDC = NULL;
	}
}
예제 #30
0
/* Close the win_pr2 driver */
static int
win_pr2_close(gx_device * dev)
{
    int code;
    int aborted = FALSE;

    win_pr2_copy_check(wdev);

    /* Free resources */

    if (!wdev->nocancel) {
	if (!wdev->hDlgModeless)
	    aborted = TRUE;
	else
	    DestroyWindow(wdev->hDlgModeless);
	wdev->hDlgModeless = 0;
    }
    if (aborted)
	AbortDoc(wdev->hdcprn);
    else
	EndDoc(wdev->hdcprn);

    DeleteDC(wdev->hdcprn);

    if (wdev->win32_hdevmode != NULL) {
	GlobalFree(wdev->win32_hdevmode);
	wdev->win32_hdevmode = NULL;
    }
    if (wdev->win32_hdevnames != NULL) {
	GlobalFree(wdev->win32_hdevnames);
	wdev->win32_hdevnames = NULL;
    }

    code = gdev_prn_close(dev);

    /* delete unwanted temporary file */
    if (wdev->fname[0])
	unlink(wdev->fname);

    return code;
}