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

📄 previewdialog_filemenu.cpp

📁 虚拟打印机
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* * * previewdialog_filemenu.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 "previewdialog.h"#include "previewdialog_switches.h"#include "prposterdatafile.h"#include "prlistviewdialog.h"#include "prpreviewutils.h"#include "resource.h"#include "viewableprintpageslist.h"#include "..\lib\buffer.h"#include "..\lib\dib.h"#include "..\lib\gdiutils.h"#include "..\lib\mathutils.h"#include "..\lib\prdatasource.h"#include "..\lib\printResizerCommon.h"#include "..\lib\prspoolerdatafile.h"#include "..\lib\prutils.h"#include "..\lib\spoolutils.h"#include "..\lib\subclasswindow.h"#include "..\lib\renderpages.h"#include "..\lib\tabdialogsctrl.h"//#include <winspool.h>#include <commctrl.h>#include <commdlg.h>#include <vector>#include <tchar.h>#include <strsafe.h>#include <stdlib.h>static const uint g_auiDefaultDPI[] = { 50, 96, 100, 200, 300, 600, 1000, 2000, 3000, 10000 };static const uint g_uiDefaultDPIIndex = 1; // 96 DPIclass MyEditSubClassWindow : public SubClassWindow {public:	enum NotificationCode {		eKDTab, eKDEsc, eKDEnter, eNone	};	MyEditSubClassWindow(		HINSTANCE hinst, 		HWND hwndEdit, 		HWND hwndNeedsNotification,		UINT msgNotification,		UINT idNotification		);	virtual ~MyEditSubClassWindow();protected:	virtual void KeyboardMsg(OUT MSGRESULT& mr, UINT msg, WPARAM wParam, LPARAM lParam);private:	HWND m_hwndEdit;	HWND m_hwndNeedsNotification;	UINT m_msgNotification;	UINT m_idNotification;};class FileNameCommDlgHookParams {public:	enum DlgBaseType { eSaveAs, eOpen };	FileNameCommDlgHookParams(		DlgBaseType dbt, 		OPENFILENAME& ofn, 		PreviewDialog& pd	) :			m_dbt(dbt), 		m_ofn(ofn), 		m_pd(pd), 		m_bDlgInited(FALSE) 		{}	BOOL ConfirmationMessage(LPCTSTR lptstrMessage, HWND hwndParent);	void ErrorMessage(LPCTSTR lptstrMessage, HWND hwndParent) ;	static FileNameCommDlgHookParams& TheirGetParams(HWND hDlg);	DlgBaseType m_dbt;	OPENFILENAME& m_ofn;	BOOL m_bDlgInited;	static UINT_PTR CALLBACK TheirGetFileNameCommDlgHook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) ;private:	static void TheirInstallParamsPtr(HWND hDlg, FileNameCommDlgHookParams& params);	static const LPTSTR their_lptstrPropName;	PreviewDialog& m_pd;};class SavePosterFileDlgHookParams : public FileNameCommDlgHookParams {public:	SavePosterFileDlgHookParams(		OPENFILENAME& ofn, 		BOOL bOriginalSelectionEnabled,		PreviewDialog& pd, 		BOOL bSaveAllOriginal	) :			FileNameCommDlgHookParams(FileNameCommDlgHookParams::eSaveAs, ofn, pd),		m_bOriginalSelectionEnabled(bOriginalSelectionEnabled),		m_bSaveAllOriginal(bSaveAllOriginal)		{}	BOOL m_bOriginalSelectionEnabled;	BOOL m_bSaveAllOriginal;	static UINT_PTR CALLBACK TheirSavePosterFileCommDlgHook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) ;};class SaveOriginalAsBitmapDlgHookParams : public FileNameCommDlgHookParams {public:	SaveOriginalAsBitmapDlgHookParams(		HINSTANCE hinst,		OPENFILENAME& ofn, 		BOOL bOriginalSelectionEnabled,		PreviewDialog& pd, 		BOOL bSaveAllOriginal, 		double dDPI,		uint uiDefaultDPIIndex,		const std::vector<uint>& vuiDPI,		const SIZED& szdOriginal_Inches,		const SIZED& szdOriginalSelection_Inches	) :			FileNameCommDlgHookParams(FileNameCommDlgHookParams::eSaveAs, ofn, pd),		m_bOriginalSelectionEnabled(bOriginalSelectionEnabled),		m_hinst(hinst),		m_bSaveAllOriginal(bSaveAllOriginal),		m_dDPI(dDPI),		m_uiDefaultDPIIndex(uiDefaultDPIIndex),		m_vuiDPI(vuiDPI),		m_szdOriginal_Inches(szdOriginal_Inches),		m_szdOriginalSelection_Inches(szdOriginalSelection_Inches)		{}	HINSTANCE m_hinst;	BOOL m_bOriginalSelectionEnabled;	BOOL m_bSaveAllOriginal;	double m_dDPI;	uint m_uiDefaultDPIIndex;	const std::vector<uint>& m_vuiDPI;	SIZED m_szdOriginal_Inches;	SIZED m_szdOriginalSelection_Inches;	static UINT_PTR CALLBACK TheirSaveOriginalAsBitmapFileCommDlgHook(		HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) ;};// ****************************************************************************************// **  class PreviewDialog FILE MENU COMMAND AND FILE DIALOG MEMBERS  *********************// ****************************************************************************************BOOL PreviewDialog::GetBitmapOpenFilename(OUT tstring& tstrFileName) {	LPTSTR lptstrFilter = TEXT("Bitmap Files\0*.bmp\0All Files\0*.*\0");	tstring tstrTitle;	this->ComposeDialogTitle(tstrTitle, TEXT("Open Bitmap File"));	// DEBUG-FIX USE TEMPLATE THAT TELLS USER RESULTS MAY BE BETTER BY PRINTING BITMAP TO US INSTEAD	BOOL bRetValue = this->GetOpenFileName(tstrFileName, tstrTitle, lptstrFilter, IDD_DIALOG_CUSTOMOPENBITMAP);	return bRetValue;}BOOL PreviewDialog::GetOpenFileName(OUT tstring& tstrFileName, IN tstring& tstrTitle, 									IN LPTSTR lptstrFilter, WORD wIDTemplate) {	BOOL bRetValue = FALSE;	TCHAR atstrFileNameBuff[MAX_PATH];	::ZeroMemory(atstrFileNameBuff, sizeof(atstrFileNameBuff));	//TCHAR atstrFileTitleBuff[MAX_PATH];	//::ZeroMemory(atstrFileTitleBuff, sizeof(atstrFileTitleBuff));	TCHAR atstrCustomFilterBuff[32];	::ZeroMemory(atstrCustomFilterBuff, sizeof(atstrCustomFilterBuff));	::OPENFILENAME ofn;	::ZeroMemory(&ofn, sizeof(ofn));	ofn.lStructSize = sizeof(ofn);	ofn.Flags = OFN_HIDEREADONLY | OFN_ENABLEHOOK  | OFN_EXPLORER;	ofn.hInstance = this->hinst();	ofn.hwndOwner = this->hdlg();	ofn.lpfnHook = FileNameCommDlgHookParams::TheirGetFileNameCommDlgHook;	ofn.lpstrCustomFilter = atstrCustomFilterBuff;	ofn.nMaxCustFilter = ARRCOUNT(atstrCustomFilterBuff)-1;	ofn.lpstrFilter = lptstrFilter;	ofn.nFilterIndex = 1;	ofn.lpstrFile = atstrFileNameBuff;	ofn.nMaxFile = ARRCOUNT(atstrFileNameBuff);	ofn.lpstrTitle = tstrTitle.c_str();	if (wIDTemplate != NULL) {		ofn.Flags |= OFN_ENABLETEMPLATE;		ofn.lpTemplateName = MAKEINTRESOURCE(wIDTemplate);	}	FileNameCommDlgHookParams params(FileNameCommDlgHookParams::eOpen, ofn, *this);	ofn.lCustData = (LPARAM) &params;	if (::GetOpenFileName(&ofn)) {		tstrFileName = ofn.lpstrFile;		bRetValue = TRUE;	} else {		if (params.m_bDlgInited) {			tstrFileName.erase();			bRetValue = TRUE;		} 	}	return bRetValue;}BOOL PreviewDialog::GetPosterOpenFileName(OUT tstring& tstrFileName) {	LPTSTR lptstrFilter = TEXT("Poster Files\0*.psr\0All Files\0*.*\0");	tstring tstrTitle;	this->ComposeDialogTitle(tstrTitle, TEXT("Open Poster File"));	BOOL bRetValue = this->GetOpenFileName(tstrFileName, tstrTitle, lptstrFilter, NULL);	return bRetValue;}BOOL PreviewDialog::GetPoserSaveFileName(OUT tstring& tstrFileName, OUT BOOL& bSourceSelection) {	BOOL bRetValue = FALSE;	TCHAR atstrFileNameBuff[MAX_PATH];	::ZeroMemory(atstrFileNameBuff, sizeof(atstrFileNameBuff));	//TCHAR atstrFileTitleBuff[MAX_PATH];	//::ZeroMemory(atstrFileTitleBuff, sizeof(atstrFileTitleBuff));	TCHAR atstrCustomFilterBuff[32];	::ZeroMemory(atstrCustomFilterBuff, sizeof(atstrCustomFilterBuff));	::OPENFILENAME ofn;	::ZeroMemory(&ofn, sizeof(ofn));	ofn.lStructSize = sizeof(ofn);	ofn.Flags = OFN_HIDEREADONLY | OFN_ENABLEHOOK | OFN_ENABLETEMPLATE | OFN_EXPLORER;	ofn.hInstance = this->hinst();	ofn.hwndOwner = this->hdlg();	ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG_CUSTOMSAVEAS);	ofn.lpfnHook = SavePosterFileDlgHookParams::TheirSavePosterFileCommDlgHook;	ofn.lpstrCustomFilter = atstrCustomFilterBuff;	ofn.nMaxCustFilter = ARRCOUNT(atstrCustomFilterBuff)-1;	ofn.lpstrFilter = TEXT("Poster Files\0*.psr\0All Files\0*.*\0");	ofn.nFilterIndex = 1;	ofn.lpstrFile = atstrFileNameBuff;	ofn.nMaxFile = ARRCOUNT(atstrFileNameBuff);	tstring tstrTitle;	this->ComposeDialogTitle(tstrTitle, TEXT("Save Poster"));	ofn.lpstrTitle = tstrTitle.c_str();	BOOL bOriginalSelectionEnabled = this->IsOriginalSelectionEnabled() && ! this->ReadOriginalAll();	SavePosterFileDlgHookParams params(ofn, bOriginalSelectionEnabled, *this, TRUE);	ofn.lCustData = (LPARAM) &params;	if (::GetSaveFileName(&ofn)) {		tstrFileName = ofn.lpstrFile;		bSourceSelection = ! params.m_bSaveAllOriginal;		bRetValue = TRUE;	} else {		if (params.m_bDlgInited) {			tstrFileName.erase();			bRetValue = TRUE;		} 	}	return bRetValue;}BOOL PreviewDialog::GetSaveOriginalAsBitmapFileName(	OUT tstring& tstrFileName, 	OUT BOOL& bSourceSelection,	OUT RECTD& rdSave_Inches, 	OUT double& dDPI	) {	BOOL bRetValue = FALSE;	TCHAR atstrFileNameBuff[MAX_PATH];	::ZeroMemory(atstrFileNameBuff, sizeof(atstrFileNameBuff));	//TCHAR atstrFileTitleBuff[MAX_PATH];	//::ZeroMemory(atstrFileTitleBuff, sizeof(atstrFileTitleBuff));	TCHAR atstrCustomFilterBuff[32];	::ZeroMemory(atstrCustomFilterBuff, sizeof(atstrCustomFilterBuff));	::OPENFILENAME ofn;	::ZeroMemory(&ofn, sizeof(ofn));	ofn.lStructSize = sizeof(ofn);	ofn.Flags = OFN_HIDEREADONLY | OFN_ENABLEHOOK | OFN_ENABLETEMPLATE | OFN_EXPLORER;	ofn.hInstance = this->hinst();	ofn.hwndOwner = this->hdlg();	ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG_CUSTOMSAVEAS_BITMAP);	ofn.lpfnHook = SaveOriginalAsBitmapDlgHookParams::TheirSaveOriginalAsBitmapFileCommDlgHook;	ofn.lpstrCustomFilter = atstrCustomFilterBuff;	ofn.nMaxCustFilter = ARRCOUNT(atstrCustomFilterBuff)-1;	ofn.lpstrFilter = TEXT("Bitmap Files\0*.bmp\0All Files\0*.*\0");	ofn.nFilterIndex = 1;	ofn.lpstrFile = atstrFileNameBuff;	ofn.nMaxFile = ARRCOUNT(atstrFileNameBuff);	tstring tstrTitle;	this->ComposeDialogTitle(tstrTitle, TEXT("Save Original Page As Bitmap"));	ofn.lpstrTitle = tstrTitle.c_str();	std::vector<uint> vuiDPI;	for(uint k = 0; k < ARRCOUNT( ::g_auiDefaultDPI ); ++k) {		vuiDPI.push_back(g_auiDefaultDPI[k]);	}	RECTD rdSelection_Inches;	BOOL bHasSelection = this->ReadSourceSelection(rdSelection_Inches);	if (!bHasSelection) {		rdSelection_Inches = m_ssResized.rdTotalImage_Inches;	}	SIZED szdOriginal_Inches = { RW(m_ssResized.rdTotalImage_Inches), RH(m_ssResized.rdTotalImage_Inches) };	SIZED szdOriginalSelection_Inches = { RW(rdSelection_Inches), RH(rdSelection_Inches) };	BOOL bOriginalSelectionEnabled = bHasSelection;	SaveOriginalAsBitmapDlgHookParams params(		this->hinst(),		ofn,		bOriginalSelectionEnabled,		*this,		TRUE,		vuiDPI[ ::g_uiDefaultDPIIndex ],		::g_uiDefaultDPIIndex,		vuiDPI,		szdOriginal_Inches,		szdOriginalSelection_Inches		);	ofn.lCustData = (LPARAM) &params;	if (::GetSaveFileName(&ofn)) {		tstrFileName = ofn.lpstrFile;		bSourceSelection = ! params.m_bSaveAllOriginal;		dDPI = params.m_dDPI;		rdSave_Inches = (bSourceSelection ? rdSelection_Inches : m_ssResized.rdTotalImage_Inches);		bRetValue = TRUE;	} else {		if (params.m_bDlgInited) {			tstrFileName.erase();			bRetValue = TRUE;		} 

⌨️ 快捷键说明

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