⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prpreviewutils.cpp

📁 虚拟打印机
💻 CPP
字号:
/*  * prpreviewutils.cpp *    Copyright (C) 2006 Michael H. Overlin   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      Contact at poster_printer@yahoo.com */#include "prpreviewutils.h"#include "..\lib\devmode.h"#include "..\lib\mathutils.h"#include "..\lib\spoolutils.h"#include "..\lib\utils.h"#include <windows.h>// ****************************************************************************************************// **  class DevModeKeeper  ***************************************************************************// ****************************************************************************************************DevModeKeeper::DevModeKeeper(const DevModeKeeper& dmk) {	*this = dmk;	//m_pdm = ::DM_Duplicate(dmk.m_pdm);	//m_tstrPrinterName = dmk.m_tstrPrinterName;}DevModeKeeper::DevModeKeeper(void) {	m_pdm = NULL;}DevModeKeeper::~DevModeKeeper() {	if (m_pdm != NULL) {		free(m_pdm);	}}::PDEVMODE DevModeKeeper::GetDevMode(const tstring &tstrPrinterName) {	if (tstrPrinterName != m_tstrPrinterName) {		m_tstrPrinterName = tstrPrinterName;		if (m_pdm != NULL) {			free(m_pdm);			m_pdm = NULL;		}		HANDLE hPrinter = NULL;		BOOL b = ::OpenPrinter( const_cast<LPTSTR>(m_tstrPrinterName.c_str()), &hPrinter, NULL);		if (b) {			DWORD dwcBuff= ::DocumentProperties(NULL, hPrinter, const_cast<LPTSTR>(m_tstrPrinterName.c_str()), NULL, NULL, 0);			m_pdm = (PDEVMODE) malloc(dwcBuff);			::DocumentProperties(NULL, hPrinter, const_cast<LPTSTR>(m_tstrPrinterName.c_str()), m_pdm, m_pdm, DM_OUT_BUFFER);			::ClosePrinter(hPrinter);		}	}	return m_pdm;}BOOL DevModeKeeper::SetDevMode(void) {	ASSERT(m_pdm != NULL);	LONG lresult = ::DoDocumentProperties(		NULL, const_cast<LPTSTR>(m_tstrPrinterName.c_str()), m_pdm,	DM_IN_BUFFER | DM_OUT_BUFFER);		BOOL bRetValue = (lresult >= 0);		//BOOL bRetValue = FALSE;	//HANDLE hPrinter = NULL;	//BOOL b = ::OpenPrinter(const_cast<LPTSTR>(m_tstrPrinterName.c_str()), &hPrinter, NULL);	//if (b) {	//	LONG lresult = ::DocumentProperties(	//		NULL, hPrinter, const_cast<LPTSTR>(m_tstrPrinterName.c_str()), m_pdm, m_pdm, DM_IN_BUFFER | DM_OUT_BUFFER);	//	bRetValue = (lresult >= 0);	//	::ClosePrinter(hPrinter);	//}	return bRetValue;}DevModeKeeper& DevModeKeeper::operator =(const DevModeKeeper& dmk) {	m_pdm = ( (dmk.m_pdm != NULL) ? ::DM_Duplicate(dmk.m_pdm) : NULL );	m_tstrPrinterName = dmk.m_tstrPrinterName;	return *this;}// **********************************************************************************// **  MODULE PUBLIC ROUTINES  ******************************************************// **********************************************************************************BOOL GetEnhMetafileFrame_Inches(OUT RECTD& rd, IN HENHMETAFILE hMeta) {	BOOL bRetValue = FALSE;	::ENHMETAHEADER enhMetaHeader;	if (::GetEnhMetaFileHeader(hMeta, sizeof(enhMetaHeader), &enhMetaHeader) != 0) {		rd.left = enhMetaHeader.rclFrame.left * INCHES_PER_MM / 100.0;		rd.top = enhMetaHeader.rclFrame.top * INCHES_PER_MM / 100.0;		rd.right = enhMetaHeader.rclFrame.right * INCHES_PER_MM / 100.0;		rd.bottom = enhMetaHeader.rclFrame.bottom * INCHES_PER_MM / 100.0;		bRetValue = TRUE;	}	return bRetValue;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -