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

📄 compress.cpp

📁 所有压缩格式的压缩解压缩。
💻 CPP
字号:
// Compress.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "Compress.h"

#include "MainFrm.h"
#include "fileinfo.h"
#include "associatedlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCompressApp

BEGIN_MESSAGE_MAP(CCompressApp, CWinApp)
	//{{AFX_MSG_MAP(CCompressApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
	ON_COMMAND(ID_APP_ASSOCIATE, OnAppAssociate)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCompressApp construction

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

/////////////////////////////////////////////////////////////////////////////
// The one and only CCompressApp object

CCompressApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CCompressApp initialization

BOOL CCompressApp::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.

	OleInitialize(NULL);

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

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(REGISTRYKEYNAME);

	m_UserData.Load();

	m_pLibmgr=new CLibManager(m_UserData.m_szCDLPath);
	m_pDoc=new CCompressDoc(m_pLibmgr);

	// To create the main window, this code creates a new frame window
	// object and then sets it as the application's main window object.

	CMainFrame* pFrame = new CMainFrame;
	m_pMainWnd = pFrame;

	// create and load the frame with its resources

	pFrame->LoadFrame(IDR_MAINFRAME,
		WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
		NULL);
	pFrame->SetIcon(LoadIcon(IDR_MAINFRAME),TRUE);

	// The one and only window has been initialized, so show and update it.
	WINDOWPLACEMENT pos;
//	pFrame->ShowWindow(SW_SHOW);
//	pFrame->UpdateWindow();
//	pFrame->GetWindowPlacement(&pos);
	pos.rcNormalPosition.left=m_UserData.m_WndPos.left;
	pos.rcNormalPosition.right=m_UserData.m_WndPos.right;
	pos.rcNormalPosition.top=m_UserData.m_WndPos.top;
	pos.rcNormalPosition.bottom=m_UserData.m_WndPos.bottom;
	pos.showCmd=m_UserData.m_ShowCmd;
	pFrame->SetWindowPlacement(&pos);

	DoCmdLine();

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CCompressApp message handlers





/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

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

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	CHyperLink	m_MyName;
	CHyperLink	m_Zlib;
	CHyperLink	m_Ziparchive;
	CHyperLink	m_Mark;
	CHyperLink	m_Kirk;
	CHyperLink	m_Gailly;
	CHyperLink	m_Dracz;
	CHyperLink	m_Cj60lib;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

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

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	DDX_Control(pDX, IDC_NAME, m_MyName);
	DDX_Control(pDX, IDC_ZLIB, m_Zlib);
	DDX_Control(pDX, IDC_ZIPARCHIVE, m_Ziparchive);
	DDX_Control(pDX, IDC_MARK, m_Mark);
	DDX_Control(pDX, IDC_KIRK, m_Kirk);
	DDX_Control(pDX, IDC_GAILLY, m_Gailly);
	DDX_Control(pDX, IDC_DRACZ, m_Dracz);
	DDX_Control(pDX, IDC_CJ60LIB, m_Cj60lib);
	//}}AFX_DATA_MAP
}

BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_MyName.SetURL(_T("mailto:qinfenglin@chinaren.com"));
	m_Zlib.SetURL(_T("ftp://ds.internic.net/rfc/rfc1950.txt"));
	m_Ziparchive.SetURL(_T(""));
	m_Mark.SetURL(_T("mailto:madler@alumni.caltech.edu"));
	m_Kirk.SetURL(_T("mailto:kstowell@codejockeys.com"));
	m_Gailly.SetURL(_T("mailto:jloup@gzip.org"));
	m_Dracz.SetURL(_T("mailto:taddracz@poczta.onet.pl"));
	m_Cj60lib.SetURL(_T("http://www.codejockeys.com/kstowell/"));

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CCompressApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CCompressApp message handlers

int CCompressApp::ExitInstance() 
{
	// TODO: Add your specialized code here and/or call the base class
	m_UserData.Save();
	delete m_pLibmgr;
	delete m_pDoc;
	DelDirTree(m_UserData.m_szTempPath+"~Zipall.tmp");

	OleUninitialize();

	return CWinApp::ExitInstance();
}

void CCompressApp::DoCmdLine()
{
	CMainFrame *pFrame=(CMainFrame*)m_pMainWnd;
	CString cmdline(m_lpCmdLine);

	if (cmdline.IsEmpty()) return;

	if (cmdline.Left(3)=="-o ")
	{
		CString fn(cmdline);
		fn.Delete(0,2);
		if (fn.IsEmpty())
			AfxMessageBox("命令行缺少文件名!");
		else if (m_pDoc->Open(fn))
			pFrame->Refrash();
		else
		{
			CString info;
			info.Format("文件%s不能打开!",fn);
			AfxMessageBox(info);
		}
		return;
	}
	else if (cmdline[0]!='-'&&cmdline[1]!=' ')
	{
		if (m_pDoc->Open(cmdline))
			pFrame->Refrash();
		else
		{
			CString info;
			info.Format("文件%s不能打开!",cmdline);
			AfxMessageBox(info);
		}
		return;
	}

	AfxMessageBox("命令行参数错误!",MB_ICONSTOP);
}

void CCompressApp::OnAppAssociate() 
{
	// TODO: Add your command handler code here
	CAssociateDlg dlg;
	dlg.DoModal();
}

⌨️ 快捷键说明

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