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

📄 scanviewer.cpp

📁 看图软件
💻 CPP
字号:
// ScanViewer.cpp : 定义应用程序的类行为。
//

#include "stdafx.h"
#include "ScanViewer.h"
#include "MainFrm.h"

#include "ScanViewerDoc.h"
#include "ScanViewerView.h"
#include ".\scanviewer.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


#define All_EXTENSION_NUMBER 10                                                 //宏定义最多输入10个目录
#define All_PHOTO_EXTENSION {"*.bmp","*.dib","*.jpg","*.jpeg","*.jpe","*.jfif","*.gif","*.tif","*.tiff","*.png"}            //储存图片的扩展名



// CScanViewerApp

BEGIN_MESSAGE_MAP(CScanViewerApp, CWinApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
	// 基于文件的标准文档命令
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
	// 标准打印设置命令
	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()


// CScanViewerApp 构造

CScanViewerApp::CScanViewerApp()
{
	// TODO: 在此处添加构造代码,
	// 将所有重要的初始化放置在 InitInstance 中
}


// 唯一的一个 CScanViewerApp 对象

CScanViewerApp theApp;

// CScanViewerApp 初始化

BOOL CScanViewerApp::InitInstance()
{
	// 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControls()。否则,将无法创建窗口。
	InitCommonControls();

	//23:12 2007-11-26
	Gdiplus::GdiplusStartupInput gdiplusStartupInput;
	Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL); 

	CWinApp::InitInstance();

	// 初始化 OLE 库
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}
	AfxEnableControlContainer();
	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO: 应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
	LoadStdProfileSettings(5);  // 加载标准 INI 文件选项(包括 MRU)
	// 注册应用程序的文档模板。文档模板
	// 将用作文档、框架窗口和视图之间的连接
	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CScanViewerDoc),
		RUNTIME_CLASS(CMainFrame),       // 主 SDI 框架窗口
		RUNTIME_CLASS(CScanViewerView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);
	// 分析标准外壳命令、DDE、打开文件操作的命令行
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);
	// 调度在命令行中指定的命令。如果
	// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	// 唯一的一个窗口已初始化,因此显示它并对其进行更新
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();
	// 仅当存在后缀时才调用 DragAcceptFiles,
	//  在 SDI 应用程序中,这应在 ProcessShellCommand  之后发生
	return TRUE;
}



// 用于应用程序“关于”菜单项的 CAboutDlg 对话框

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// 对话框数据
	enum { IDD = IDD_ABOUTBOX };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

// 实现
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()

// 用于运行对话框的应用程序命令
void CScanViewerApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}


// CScanViewerApp 消息处理程序


int CScanViewerApp::ExitInstance()
{
	// TODO: 在此添加专用代码和/或调用基类
	Gdiplus::GdiplusShutdown(m_gdiplusToken);    //23:12 2007-11-26

	return CWinApp::ExitInstance();
}



//idcomcn2007
//0:05 2007-10-11
//
void CScanViewerApp::GetFirstMRUDir(CString & strDirPath)
{
	if	(m_pRecentFileList == NULL) { strDirPath=""; return;}

	ASSERT(   m_pRecentFileList->GetSize()   >   0);   
	strDirPath   =   (*m_pRecentFileList)[0];  
	strDirPath=strDirPath.Left(strDirPath.ReverseFind('\\'));
	if (strDirPath.Right(1)!="\\")	strDirPath+="\\";	
	
	//Verifies that a path is a valid directory. 		
	if (!PathIsDirectory(strDirPath)) strDirPath="";
}


//idcomcn2008
//12:37 2008-5-24
//显示整数,用于测试
void CScanViewerApp::IntegerToStringForTest(int iCount,int iA,int iB,int iC,int iD,int iE)
{
	if (iCount<=0||iCount>5) return;
	
	CString strShow;
	switch(iCount)
	{
	case 1:
		strShow.Format("iA=%d\n",iA);
		break;
	case 2:
		strShow.Format("iA=%d,\niB=%d\n",iA,iB);
		break;
	case 3:
		strShow.Format("iA=%d,\niB=%d,\niC=%d\n",iA,iB,iC);
		break;
	case 4:
		strShow.Format("iA=%d,\niB=%d,\niC=%d,\niD=%d\n",iA,iB,iC,iD);
		break;
	case 5:
		strShow.Format("iA=%d,\niB=%d,\niC=%d,\niD=%d,\niE=%d\n",iA,iB,iC,iD,iE);
		break;
	default:
		strShow.Format("当前没有需要显示的整数!");
		break;
	}
	AfxMessageBox(strShow);
}



// 判断是否为图片文件(通过文件扩展名),真返回TRUE,假返回FLASE
BOOL CScanViewerApp::IsPhotoFile(LPCTSTR pszFileName)
{
	CString strPhotoFile=pszFileName;
	BOOL bReturn=FALSE;
	CStringArray strENArray;
	CString strExpandName[All_EXTENSION_NUMBER]=All_PHOTO_EXTENSION;                           //储存图片的扩展名
	for (int i=0;i<All_EXTENSION_NUMBER;i++)	strENArray.Add(strExpandName[i]);

	//比较扩展名
	for (int nj=0;nj<strENArray.GetCount();nj++)                      //获取所有图片的数目			
	{
		if (strENArray.GetAt(nj).Right(4).MakeLower()==strPhotoFile.Right(4).MakeLower()) 
		{
			bReturn=TRUE;
			break;
		}
	}

	//AfxMessageBox(pszFileName);
	return bReturn;
}

⌨️ 快捷键说明

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