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

📄 dmreader.cpp

📁 swf 格式文件(Flash)阅读器.根据 Flash 文件窗口的大小自适应调整阅读器窗口大小。直持压缩过 swf 文件。如果为 *.exe 格式 Flash 文件可用 Exe2Swf 程序进行分解为
💻 CPP
字号:
// DmReader.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "DmReader.h"
#include "DmReaderDlg.h"

#include <sys/stat.h>		// _FileExist\_IsDirectory
#include <io.h>				// _FileExist\_IsDirectory
#include <tlhelp32.h>		// GlbIsProgRun

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////////////////////////////////////////
// Glob Funcs

void CreateAllDirectories(CString strDir)
{
	if(strDir.Right(1)=="\\")
		strDir=strDir.Left(strDir.GetLength()-1); 
	
	if(GetFileAttributes(strDir)!=-1) 
		return;
	
	int nFound = strDir.ReverseFind('\\');
	CreateAllDirectories(strDir.Left(nFound)); 
	
	CreateDirectory(strDir,NULL); 
}

void GlbRecursiveDeleteDir(LPCTSTR lpszPath)
{
	CFileFind ff;
	CString path = lpszPath;
	
	if(path.Right(1) != "\\")
		path += "\\";
	
	path += "*.*";
	
	BOOL res = ff.FindFile(path);
	
	while(res)
	{
		res = ff.FindNextFile();
		if (ff.IsDots())
			continue;
		
		if (ff.IsDirectory())
		{
			path = ff.GetFilePath();
			GlbRecursiveDeleteDir(path);
			RemoveDirectory(path);
		}
		else
		{
			CString strFile = ff.GetFilePath();
			::SetFileAttributes(strFile, FILE_ATTRIBUTE_NORMAL);
			DeleteFile(strFile);
		}
	}
	
	::SetFileAttributes(lpszPath, FILE_ATTRIBUTE_NORMAL);
	ff.Close();
	RemoveDirectory(lpszPath);
}

// -ZYZ- [5/12/2005] - 文件是否存在
bool _FileExist(const char* FileName)
{
	struct stat my_stat;
	return (stat(FileName, &my_stat) == 0);
}

// -ZYZ- [5/12/2005] - 是否是有效的目录
bool _IsDirectory(const char* FileName)
{
	struct stat my_stat;
	if (stat(FileName, &my_stat) != 0) return false;
	return ((my_stat.st_mode & S_IFDIR) != 0);
}

// -ZYZ- [5/8/2005] - 获取应用程序的完全路径
CString GlbGetAppPath()
{
	CString strPath;
	GetModuleFileName(NULL,strPath.GetBuffer(_MAX_PATH),_MAX_PATH);
	strPath.ReleaseBuffer();
	int n = strPath.ReverseFind('\\');
	if( n >= 0 )
		strPath = strPath.Left(n);
	return strPath;
}

// -ZYZ- [5/12/2005] - 判断是否是有效的文件
BOOL GlbIsValidFile(LPCTSTR lpszFile)
{
	CString sFile = lpszFile;
	if(sFile.IsEmpty())
		return FALSE;

	if(_FileExist(lpszFile) && !_IsDirectory(lpszFile))
		return TRUE;
	return FALSE;
}

// -ZYZ- [5/12/2005] - 判断是否是有效的目录
BOOL GlbIsValidDirectory(LPCTSTR lpszDirectory)
{
	CString sDir = lpszDirectory;
	if(sDir.IsEmpty())
		return FALSE;

	if(_IsDirectory(lpszDirectory))
		return TRUE;
	return FALSE;
}

//全局函数:某个程序是否在运行,如果成功,返回全路经,否则返回空字符
CString GlbIsProgRun(LPCTSTR lpszProg)
{
	CString sProg = lpszProg;
	if(sProg.IsEmpty())
		return _T("");

	HANDLE handle=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);	
	PROCESSENTRY32* info=new PROCESSENTRY32;
    info->dwSize=sizeof(PROCESSENTRY32);
	if(Process32First(handle,info))
	{
		if(GetLastError()!=ERROR_NO_MORE_FILES )
		{
			while(Process32Next(handle,info)!=FALSE)
			{
				UINT uPID = info->th32ProcessID;
				CString sExe = info->szExeFile;
				sExe.MakeLower();
				if(sExe.Find(lpszProg) >= 0)
				{
				   if(uPID != 0)
				   {
						CloseHandle(handle);	
						delete info;
						return sExe;
				   }
				}
			}
		}
	}
   CloseHandle(handle);	
   delete info;
   return _T("");
}

// 获取电子书窗口
HWND GlbFindEBookWnd(LONG nData)
{
	HWND hWnd;
	LONG lWndData;
	DWORD dwStyle;
	hWnd = ::GetTopWindow(NULL);
	while(hWnd != NULL)
	{
		dwStyle = ::GetWindowLong(hWnd, GWL_STYLE);
		lWndData = ::GetWindowLong(hWnd, GWL_USERDATA);
		if(!(dwStyle & WS_CHILD) && (lWndData == nData))
		{
			return hWnd;
		}
		hWnd =::GetNextWindow(hWnd,GW_HWNDNEXT);
	}
	return NULL;
}

/////////////////////////////////////////////////////////////////////////////
// CDmReaderApp

BEGIN_MESSAGE_MAP(CDmReaderApp, CWinApp)
	//{{AFX_MSG_MAP(CDmReaderApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDmReaderApp construction

CDmReaderApp::CDmReaderApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CDmReaderApp object

CDmReaderApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CDmReaderApp initialization

BOOL CDmReaderApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	CString strCmdLine = m_lpCmdLine;

	strCmdLine.TrimLeft("\"");
	strCmdLine.TrimRight("\"");

	strCmdLine.TrimLeft("\"");
	strCmdLine.TrimRight("\"");

	CDmReaderDlg dlg;
	dlg.m_sBookFile = strCmdLine;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

BOOL CDmReaderApp::PreTranslateMessage(MSG* pMsg) 
{
	if(pMsg->message == WM_RBUTTONDOWN || pMsg->message == WM_RBUTTONUP)
	{
		// -ZYZ- [5/16/2005] - 屏蔽右键(右键退出全屏幕)
		ExistFullScreen();
		return TRUE;
	}
	else if(pMsg->message == WM_KEYDOWN)
	{
		if(pMsg->wParam == VK_ESCAPE)		// -ZYZ- [5/17/2005] - ESC键退出全屏幕
		{
			ExistFullScreen();
		}
		else if(pMsg->wParam == 93)			// -ZYZ- [5/17/2005] - 屏蔽上下文菜单键
		{
			return TRUE;
		}
	}
	
	return CWinApp::PreTranslateMessage(pMsg);
}

// -ZYZ- [5/22/2005] - 退出全屏幕
void CDmReaderApp::ExistFullScreen()
{
	CDmReaderDlg* pMainDlg = (CDmReaderDlg*)AfxGetMainWnd();
	if(pMainDlg->m_bFullScreen)
		pMainDlg->OnMenuFullScreen();
}

⌨️ 快捷键说明

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